Skip to content

Commit 444877a

Browse files
committed
Polishing
(cherry picked from commit 8fe1de4)
1 parent 57b62dd commit 444877a

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class AotBeanProcessingException extends AotProcessingException {
3131

3232
private final RootBeanDefinition beanDefinition;
3333

34+
3435
/**
3536
* Create an instance with the {@link RegisteredBean} that fails to be
3637
* processed, a detail message, and an optional root cause.
@@ -64,6 +65,7 @@ private static String createErrorMessage(RegisteredBean registeredBean, String m
6465
return sb.toString();
6566
}
6667

68+
6769
/**
6870
* Return the bean definition of the bean that failed to be processed.
6971
*/

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,13 @@ public void applyTo(GenerationContext generationContext, BeanRegistrationCode be
885885
});
886886
GeneratedMethod generateMethod = generatedClass.getMethods().add("apply", method -> {
887887
method.addJavadoc("Apply resource autowiring.");
888-
method.addModifiers(javax.lang.model.element.Modifier.PUBLIC,
889-
javax.lang.model.element.Modifier.STATIC);
888+
method.addModifiers(javax.lang.model.element.Modifier.PUBLIC, javax.lang.model.element.Modifier.STATIC);
890889
method.addParameter(RegisteredBean.class, REGISTERED_BEAN_PARAMETER);
891890
method.addParameter(this.target, INSTANCE_PARAMETER);
892891
method.returns(this.target);
893-
method.addCode(generateMethodCode(generatedClass.getName(),
894-
generationContext.getRuntimeHints()));
892+
method.addCode(generateMethodCode(generatedClass.getName(), generationContext.getRuntimeHints()));
895893
});
896894
beanRegistrationCode.addInstancePostProcessor(generateMethod.toMethodReference());
897-
898895
registerHints(generationContext.getRuntimeHints());
899896
}
900897

spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -856,12 +856,11 @@ private CodeBlock generateResourceToInjectCode(
856856
return CodeBlock.of("$L($L)", generatedMethod.getName(), REGISTERED_BEAN_PARAMETER);
857857
}
858858

859-
@SuppressWarnings("NullAway")
860859
private void generateGetEntityManagerMethod(MethodSpec.Builder method, PersistenceElement injectedElement) {
861860
String unitName = injectedElement.unitName;
862861
Properties properties = injectedElement.properties;
863862
method.addJavadoc("Get the '$L' {@link $T}.",
864-
(StringUtils.hasLength(unitName)) ? unitName : "default",
863+
(StringUtils.hasLength(unitName) ? unitName : "default"),
865864
EntityManager.class);
866865
method.addModifiers(javax.lang.model.element.Modifier.PUBLIC,
867866
javax.lang.model.element.Modifier.STATIC);
@@ -871,18 +870,16 @@ private void generateGetEntityManagerMethod(MethodSpec.Builder method, Persisten
871870
"$T entityManagerFactory = $T.findEntityManagerFactory(($T) $L.getBeanFactory(), $S)",
872871
EntityManagerFactory.class, EntityManagerFactoryUtils.class,
873872
ListableBeanFactory.class, REGISTERED_BEAN_PARAMETER, unitName);
874-
boolean hasProperties = !CollectionUtils.isEmpty(properties);
875-
if (hasProperties) {
876-
method.addStatement("$T properties = new Properties()",
877-
Properties.class);
873+
if (properties != null) {
874+
method.addStatement("$T properties = new Properties()", Properties.class);
878875
for (String propertyName : new TreeSet<>(properties.stringPropertyNames())) {
879876
method.addStatement("properties.put($S, $S)", propertyName, properties.getProperty(propertyName));
880877
}
881878
}
882879
method.addStatement(
883880
"return $T.createSharedEntityManager(entityManagerFactory, $L, $L)",
884881
SharedEntityManagerCreator.class,
885-
(hasProperties) ? "properties" : null,
882+
(properties != null ? "properties" : null),
886883
injectedElement.synchronizedWithTransaction);
887884
}
888885
}

0 commit comments

Comments
 (0)