Skip to content

Commit 2ce75dc

Browse files
committed
Polishing
1 parent 8b3ddee commit 2ce75dc

File tree

7 files changed

+23
-30
lines changed

7 files changed

+23
-30
lines changed

spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public boolean matches(Method method, Class<?> targetClass) {
8282

8383
@Override
8484
public boolean equals(@Nullable Object other) {
85-
return (this == other || (other instanceof JCacheOperationSourcePointcut otherPc &&
86-
ObjectUtils.nullSafeEquals(this.cacheOperationSource, otherPc.cacheOperationSource)));
85+
return (this == other || (other instanceof JCacheOperationSourcePointcut that &&
86+
ObjectUtils.nullSafeEquals(this.cacheOperationSource, that.cacheOperationSource)));
8787
}
8888

8989
@Override

spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationSourcePointcut.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public boolean matches(Method method, Class<?> targetClass) {
5858

5959
@Override
6060
public boolean equals(@Nullable Object other) {
61-
return (this == other || (other instanceof CacheOperationSourcePointcut otherPc &&
62-
ObjectUtils.nullSafeEquals(this.cacheOperationSource, otherPc.cacheOperationSource)));
61+
return (this == other || (other instanceof CacheOperationSourcePointcut that &&
62+
ObjectUtils.nullSafeEquals(this.cacheOperationSource, that.cacheOperationSource)));
6363
}
6464

6565
@Override

spring-context/src/main/java/org/springframework/context/annotation/PropertySourceRegistry.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,14 +42,12 @@ class PropertySourceRegistry {
4242

4343
private final List<PropertySourceDescriptor> descriptors;
4444

45+
4546
public PropertySourceRegistry(PropertySourceProcessor propertySourceProcessor) {
4647
this.propertySourceProcessor = propertySourceProcessor;
4748
this.descriptors = new ArrayList<>();
4849
}
4950

50-
public List<PropertySourceDescriptor> getDescriptors() {
51-
return Collections.unmodifiableList(this.descriptors);
52-
}
5351

5452
/**
5553
* Process the given <code>@PropertySource</code> annotation metadata.
@@ -70,12 +68,16 @@ void processPropertySource(AnnotationAttributes propertySource) throws IOExcepti
7068
boolean ignoreResourceNotFound = propertySource.getBoolean("ignoreResourceNotFound");
7169

7270
Class<? extends PropertySourceFactory> factoryClass = propertySource.getClass("factory");
73-
Class<? extends PropertySourceFactory> factorClassToUse =
71+
Class<? extends PropertySourceFactory> factoryClassToUse =
7472
(factoryClass != PropertySourceFactory.class ? factoryClass : null);
75-
PropertySourceDescriptor descriptor = new PropertySourceDescriptor(Arrays.asList(locations), ignoreResourceNotFound, name,
76-
factorClassToUse, encoding);
73+
PropertySourceDescriptor descriptor = new PropertySourceDescriptor(Arrays.asList(locations),
74+
ignoreResourceNotFound, name, factoryClassToUse, encoding);
7775
this.propertySourceProcessor.processPropertySource(descriptor);
7876
this.descriptors.add(descriptor);
7977
}
8078

79+
public List<PropertySourceDescriptor> getDescriptors() {
80+
return Collections.unmodifiableList(this.descriptors);
81+
}
82+
8183
}

spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
2323
import java.lang.annotation.RetentionPolicy;
2424
import java.lang.annotation.Target;
2525
import java.util.Collections;
26-
import java.util.Iterator;
2726
import java.util.Properties;
2827

2928
import jakarta.inject.Inject;
@@ -56,29 +55,23 @@ class PropertySourceAnnotationTests {
5655

5756
@Test
5857
void withExplicitName() {
59-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
60-
ctx.register(ConfigWithExplicitName.class);
61-
ctx.refresh();
58+
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithExplicitName.class);
6259
assertThat(ctx.getEnvironment().getPropertySources().contains("p1")).as("property source p1 was not added").isTrue();
6360
assertThat(ctx.getBean(TestBean.class).getName()).isEqualTo("p1TestBean");
6461

6562
// assert that the property source was added last to the set of sources
66-
String name;
6763
MutablePropertySources sources = ctx.getEnvironment().getPropertySources();
68-
Iterator<org.springframework.core.env.PropertySource<?>> iterator = sources.iterator();
69-
do {
70-
name = iterator.next().getName();
71-
}
72-
while (iterator.hasNext());
73-
64+
String name = sources.stream().toList().get(sources.size() - 1).getName();
7465
assertThat(name).isEqualTo("p1");
7566
ctx.close();
7667
}
7768

7869
@Test
7970
void withImplicitName() {
8071
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithImplicitName.class);
81-
assertThat(ctx.getEnvironment().getPropertySources().contains("class path resource [org/springframework/context/annotation/p1.properties]")).as("property source p1 was not added").isTrue();
72+
String name = "class path resource [org/springframework/context/annotation/p1.properties]";
73+
assertThat(ctx.getEnvironment().getPropertySources().contains(name))
74+
.as("property source p1 was not added").isTrue();
8275
assertThat(ctx.getBean(TestBean.class).getName()).isEqualTo("p1TestBean");
8376
ctx.close();
8477
}
@@ -540,7 +533,6 @@ static class ConfigWithEmptyResourceLocations {
540533
})
541534
@Configuration
542535
static class ConfigWithSameSourceImportedInDifferentOrder {
543-
544536
}
545537

546538

spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
343343
bw.setPropertyValue(pd.getName(), value);
344344
}
345345
catch (TypeMismatchException ex) {
346-
if (value == null && this.primitivesDefaultedForNullValue) {
346+
if (value == null && isPrimitivesDefaultedForNullValue()) {
347347
if (logger.isDebugEnabled()) {
348348
String propertyType = ClassUtils.getQualifiedName(pd.getPropertyType());
349349
logger.debug("""

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ protected Class<?> resolveTargetClass(MethodParameter parameter, Message<?> mess
197197
/**
198198
* Validate the payload if applicable.
199199
* <p>The default implementation checks for {@code @jakarta.validation.Valid},
200-
* Spring's {@link Validated},
201-
* and custom annotations whose name starts with "Valid".
200+
* Spring's {@link Validated}, and custom annotations whose name starts with "Valid".
202201
* @param message the currently processed message
203202
* @param parameter the method parameter
204203
* @param target the target payload object

spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public boolean matches(Method method, Class<?> targetClass) {
5757

5858
@Override
5959
public boolean equals(@Nullable Object other) {
60-
return (this == other || (other instanceof TransactionAttributeSourcePointcut otherPc &&
61-
ObjectUtils.nullSafeEquals(this.transactionAttributeSource, otherPc.transactionAttributeSource)));
60+
return (this == other || (other instanceof TransactionAttributeSourcePointcut that &&
61+
ObjectUtils.nullSafeEquals(this.transactionAttributeSource, that.transactionAttributeSource)));
6262
}
6363

6464
@Override

0 commit comments

Comments
 (0)