Skip to content

Commit b6aa689

Browse files
committed
Polishing
1 parent 4190209 commit b6aa689

File tree

7 files changed

+30
-37
lines changed

7 files changed

+30
-37
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotContribution.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public interface BeanRegistrationAotContribution {
4040
* default code generation isn't suitable.
4141
* @param generationContext the generation context
4242
* @param codeFragments the existing code fragments
43-
* @return the code fragments to use, may be the original instance or a
44-
* wrapper
43+
* @return the code fragments to use, may be the original instance or a wrapper
4544
*/
4645
default BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments(
4746
GenerationContext generationContext, BeanRegistrationCodeFragments codeFragments) {
@@ -77,8 +76,7 @@ public BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments(
7776
return defaultCodeFragments.apply(codeFragments);
7877
}
7978
@Override
80-
public void applyTo(GenerationContext generationContext,
81-
BeanRegistrationCode beanRegistrationCode) {
79+
public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) {
8280
}
8381
};
8482
}

spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131

3232
/**
3333
* Generate the various fragments of code needed to register a bean.
34-
* <p>
35-
* A default implementation is provided that suits most needs and custom code
34+
*
35+
* <p>A default implementation is provided that suits most needs and custom code
3636
* fragments are only expected to be used by library authors having built custom
3737
* arrangement on top of the core container.
38-
* <p>
39-
* Users are not expected to implement this interface directly, but rather extends
40-
* from {@link BeanRegistrationCodeFragmentsDecorator} and only override the
41-
* necessary method(s).
38+
*
39+
* <p>Users are not expected to implement this interface directly, but rather
40+
* extends from {@link BeanRegistrationCodeFragmentsDecorator} and only override
41+
* the necessary method(s).
42+
*
4243
* @author Phillip Webb
4344
* @author Stephane Nicoll
4445
* @since 6.0
@@ -48,12 +49,12 @@
4849
public interface BeanRegistrationCodeFragments {
4950

5051
/**
51-
* The variable name to used when creating the bean definition.
52+
* The variable name used when creating the bean definition.
5253
*/
5354
String BEAN_DEFINITION_VARIABLE = "beanDefinition";
5455

5556
/**
56-
* The variable name to used when creating the bean definition.
57+
* The variable name used when creating the bean definition.
5758
*/
5859
String INSTANCE_SUPPLIER_VARIABLE = "instanceSupplier";
5960

@@ -69,8 +70,7 @@ public interface BeanRegistrationCodeFragments {
6970

7071
/**
7172
* Generate the code that defines the new bean definition instance.
72-
* <p>
73-
* This should declare a variable named {@value BEAN_DEFINITION_VARIABLE}
73+
* <p>This should declare a variable named {@value BEAN_DEFINITION_VARIABLE}
7474
* so that further fragments can refer to the variable to further tune
7575
* the bean definition.
7676
* @param generationContext the generation context
@@ -94,14 +94,13 @@ CodeBlock generateSetBeanDefinitionPropertiesCode(
9494

9595
/**
9696
* Generate the code that sets the instance supplier on the bean definition.
97-
* <p>
98-
* The {@code postProcessors} represent methods to be exposed once the
97+
* <p>The {@code postProcessors} represent methods to be exposed once the
9998
* instance has been created to further configure it. Each method should
10099
* accept two parameters, the {@link RegisteredBean} and the bean
101100
* instance, and should return the modified bean instance.
102101
* @param generationContext the generation context
103102
* @param beanRegistrationCode the bean registration code
104-
* @param instanceSupplierCode the instance supplier code supplier code
103+
* @param instanceSupplierCode the instance supplier code
105104
* @param postProcessors any instance post processors that should be applied
106105
* @return the generated code
107106
* @see #generateInstanceSupplierCode

spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class BeanRegistrationCodeGenerator implements BeanRegistrationCode {
5858
this.codeFragments = codeFragments;
5959
}
6060

61+
6162
@Override
6263
public ClassName getClassName() {
6364
return this.className;

spring-beans/src/main/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public CodeBlock generateReturnCode(
246246
}
247247

248248
private boolean hasInstanceSupplier() {
249-
return this.registeredBean.getMergedBeanDefinition().getInstanceSupplier() != null;
249+
return (this.registeredBean.getMergedBeanDefinition().getInstanceSupplier() != null);
250250
}
251251

252252
}

spring-context/src/main/java/org/springframework/context/aot/BeanFactoryInitializationAotContributions.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
import org.springframework.lang.Nullable;
3232

3333
/**
34-
* A collection of {@link BeanFactoryInitializationAotContribution AOT
35-
* contributions} obtained from {@link BeanFactoryInitializationAotProcessor AOT
36-
* processors}.
34+
* A collection of {@link BeanFactoryInitializationAotContribution AOT contributions}
35+
* obtained from {@link BeanFactoryInitializationAotProcessor AOT processors}.
3736
*
3837
* @author Phillip Webb
3938
* @since 6.0
@@ -47,23 +46,21 @@ class BeanFactoryInitializationAotContributions {
4746
this(beanFactory, AotServices.factoriesAndBeans(beanFactory));
4847
}
4948

50-
BeanFactoryInitializationAotContributions(DefaultListableBeanFactory beanFactory,
51-
AotServices.Loader loader) {
49+
BeanFactoryInitializationAotContributions(DefaultListableBeanFactory beanFactory, AotServices.Loader loader) {
5250
this.contributions = getContributions(beanFactory, getProcessors(loader));
5351
}
5452

5553

56-
private static List<BeanFactoryInitializationAotProcessor> getProcessors(
57-
AotServices.Loader loader) {
54+
private static List<BeanFactoryInitializationAotProcessor> getProcessors(AotServices.Loader loader) {
5855
List<BeanFactoryInitializationAotProcessor> processors = new ArrayList<>(
5956
loader.load(BeanFactoryInitializationAotProcessor.class).asList());
6057
processors.add(new RuntimeHintsBeanFactoryInitializationAotProcessor());
6158
return Collections.unmodifiableList(processors);
6259
}
6360

6461
private List<BeanFactoryInitializationAotContribution> getContributions(
65-
DefaultListableBeanFactory beanFactory,
66-
List<BeanFactoryInitializationAotProcessor> processors) {
62+
DefaultListableBeanFactory beanFactory, List<BeanFactoryInitializationAotProcessor> processors) {
63+
6764
List<BeanFactoryInitializationAotContribution> contributions = new ArrayList<>();
6865
for (BeanFactoryInitializationAotProcessor processor : processors) {
6966
BeanFactoryInitializationAotContribution contribution = processAheadOfTime(processor, beanFactory);
@@ -75,8 +72,8 @@ private List<BeanFactoryInitializationAotContribution> getContributions(
7572
}
7673

7774
@Nullable
78-
private BeanFactoryInitializationAotContribution processAheadOfTime(BeanFactoryInitializationAotProcessor processor,
79-
DefaultListableBeanFactory beanFactory) {
75+
private BeanFactoryInitializationAotContribution processAheadOfTime(
76+
BeanFactoryInitializationAotProcessor processor, DefaultListableBeanFactory beanFactory) {
8077

8178
try {
8279
return processor.processAheadOfTime(beanFactory);
@@ -92,6 +89,7 @@ private BeanFactoryInitializationAotContribution processAheadOfTime(BeanFactoryI
9289

9390
void applyTo(GenerationContext generationContext,
9491
BeanFactoryInitializationCode beanFactoryInitializationCode) {
92+
9593
for (BeanFactoryInitializationAotContribution contribution : this.contributions) {
9694
contribution.applyTo(generationContext, beanFactoryInitializationCode);
9795
}

spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateQueryException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public HibernateQueryException(QueryException ex) {
4040
* Return the HQL query string that was invalid.
4141
*/
4242
@Nullable
43-
@SuppressWarnings("NullAway")
4443
public String getQueryString() {
45-
return ((QueryException) getCause()).getQueryString();
44+
QueryException cause = (QueryException) getCause();
45+
return (cause != null ? cause.getQueryString() : null);
4646
}
4747

4848
}

spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public class LocalSessionFactoryBuilder extends Configuration {
120120

121121
private final ResourcePatternResolver resourcePatternResolver;
122122

123-
@Nullable
124123
private TypeFilter[] entityTypeFilters = DEFAULT_ENTITY_TYPE_FILTERS;
125124

126125

@@ -379,11 +378,9 @@ else if (className.endsWith(PACKAGE_INFO_SUFFIX)) {
379378
* the current class descriptor contained in the metadata reader.
380379
*/
381380
private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException {
382-
if (this.entityTypeFilters != null) {
383-
for (TypeFilter filter : this.entityTypeFilters) {
384-
if (filter.match(reader, readerFactory)) {
385-
return true;
386-
}
381+
for (TypeFilter filter : this.entityTypeFilters) {
382+
if (filter.match(reader, readerFactory)) {
383+
return true;
387384
}
388385
}
389386
return false;

0 commit comments

Comments
 (0)