Skip to content

Commit bc9ebb7

Browse files
arefbehboudimp911de
authored andcommitted
Cleanup code.
Closes #3592
1 parent 8ac6c02 commit bc9ebb7

File tree

9 files changed

+15
-14
lines changed

9 files changed

+15
-14
lines changed

spring-data-envers/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public Page<Revision<N, T>> findRevisions(ID id, Pageable pageable) {
172172

173173
AuditQuery baseQuery = createBaseQuery(id);
174174

175-
List<AuditOrder> orderMapped = (pageable.getSort()instanceof RevisionSort revisionSort)
175+
List<AuditOrder> orderMapped = (pageable.getSort() instanceof RevisionSort revisionSort)
176176
? List.of(mapRevisionSort(revisionSort))
177177
: mapPropertySort(pageable.getSort());
178178

spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class JpaMetamodelMappingContext
5454
*/
5555
public JpaMetamodelMappingContext(Set<Metamodel> models) {
5656

57-
Assert.notNull(models, "JPA metamodel must not be null");
5857
Assert.notEmpty(models, "JPA metamodel must not be empty");
5958

6059
this.models = new Metamodels(models);

spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentEntityImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public JpaPersistentEntityImpl(TypeInformation<T> information, ProxyIdAccessor p
5858

5959
super(information, null);
6060

61-
Assert.notNull(proxyIdAccessor, "ProxyIdAccessor must not be null");
6261
this.proxyIdAccessor = proxyIdAccessor;
6362
this.metamodel = metamodel;
6463
}

spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/JpaClassUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private JpaClassUtils() {}
4747
*/
4848
public static boolean isEntityManagerOfType(EntityManager em, String type) {
4949

50-
EntityManager entityManagerToUse = em.getDelegate()instanceof EntityManager delegate //
50+
EntityManager entityManagerToUse = em.getDelegate() instanceof EntityManager delegate //
5151
? delegate //
5252
: em;
5353

spring-data-jpa/src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public String getCommentHintKey() {
198198

199199
private static final Collection<PersistenceProvider> ALL = List.of(HIBERNATE, ECLIPSELINK, GENERIC_JPA);
200200

201-
static ConcurrentReferenceHashMap<Class<?>, PersistenceProvider> CACHE = new ConcurrentReferenceHashMap<>();
201+
private static final ConcurrentReferenceHashMap<Class<?>, PersistenceProvider> CACHE = new ConcurrentReferenceHashMap<>();
202202
private final Iterable<String> entityManagerClassNames;
203203
private final Iterable<String> metamodelClassNames;
204204

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public String applySorting(Sort sort, @Nullable String alias) {
119119

120120
Select selectStatement = parseSelectStatement(queryString);
121121

122-
if (selectStatement instanceof SetOperationList setOperationList) {
122+
if (selectStatement instanceof SetOperationList setOperationList) {
123123
return applySortingToSetOperationList(setOperationList, sort);
124124
}
125125

@@ -217,7 +217,7 @@ private Set<String> getJoinAliases(String query) {
217217
}
218218

219219
Select selectStatement = (Select) statement;
220-
if (selectStatement instanceof PlainSelect selectBody) {
220+
if (selectStatement instanceof PlainSelect selectBody) {
221221
return getJoinAliases(selectBody);
222222
}
223223

@@ -315,7 +315,7 @@ private String detectAlias(String query) {
315315
* ValuesStatement has no alias
316316
* SetOperation can have multiple alias for each operation item
317317
*/
318-
if (!(selectStatement instanceof PlainSelect selectBody)) {
318+
if (!(selectStatement instanceof PlainSelect selectBody)) {
319319
return null;
320320
}
321321

@@ -370,7 +370,7 @@ public String createCountQueryFor(@Nullable String countProjection) {
370370
/*
371371
We only support count queries for {@link PlainSelect}.
372372
*/
373-
if (!(selectStatement instanceof PlainSelect selectBody)) {
373+
if (!(selectStatement instanceof PlainSelect selectBody)) {
374374
return this.query.getQueryString();
375375
}
376376

@@ -413,7 +413,7 @@ public String getProjection() {
413413

414414
Select selectBody = selectStatement;
415415

416-
if (selectStatement instanceof SetOperationList setOperationList) {
416+
if (selectStatement instanceof SetOperationList setOperationList) {
417417

418418
// using the first one since for setoperations the projection has to be the same
419419
selectBody = setOperationList.getSelects().get(0);

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/QueryParameterSetterFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private static class ExpressionBasedQueryParameterSetterFactory extends QueryPar
186186
@Override
187187
public QueryParameterSetter create(ParameterBinding binding, DeclaredQuery declaredQuery) {
188188

189-
if (!(binding.getOrigin()instanceof ParameterBinding.Expression e)) {
189+
if (!(binding.getOrigin() instanceof ParameterBinding.Expression e)) {
190190
return null;
191191
}
192192

@@ -239,7 +239,7 @@ public QueryParameterSetter create(ParameterBinding binding, DeclaredQuery decla
239239
Assert.notNull(binding, "Binding must not be null");
240240

241241
JpaParameter parameter;
242-
if (!(binding.getOrigin()instanceof MethodInvocationArgument mia)) {
242+
if (!(binding.getOrigin() instanceof MethodInvocationArgument mia)) {
243243
return QueryParameterSetter.NOOP;
244244
}
245245

spring-data-jpa/src/main/java/org/springframework/data/jpa/util/JpaMetamodelCacheCleanup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class JpaMetamodelCacheCleanup implements DisposableBean {
3131

3232
@Override
33-
public void destroy() throws Exception {
33+
public void destroy() {
3434
JpaMetamodel.clear();
3535
}
3636
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/provider/PersistenceProviderUnitTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import jakarta.persistence.EntityManager;
2323

2424
import java.util.Arrays;
25+
import java.util.Map;
2526

2627
import org.assertj.core.api.Assumptions;
2728
import org.hibernate.Version;
@@ -32,6 +33,7 @@
3233
import org.springframework.asm.ClassWriter;
3334
import org.springframework.asm.Opcodes;
3435
import org.springframework.instrument.classloading.ShadowingClassLoader;
36+
import org.springframework.test.util.ReflectionTestUtils;
3537
import org.springframework.util.ClassUtils;
3638

3739
/**
@@ -48,7 +50,8 @@ class PersistenceProviderUnitTests {
4850
@BeforeEach
4951
void setup() {
5052

51-
PersistenceProvider.CACHE.clear();
53+
Map<?, ?> cache = (Map<?, ?>) ReflectionTestUtils.getField(PersistenceProvider.class, "CACHE");
54+
cache.clear();
5255

5356
this.shadowingClassLoader = new ShadowingClassLoader(getClass().getClassLoader());
5457
}

0 commit comments

Comments
 (0)