Polishing
Backport Bot / build (push) Waiting to run Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:ubuntu-latest name:Linux]) (push) Waiting to run Details
Deploy Docs / Dispatch docs deployment (push) Waiting to run Details

This commit is contained in:
Juergen Hoeller 2025-06-24 21:58:39 +02:00
parent 4190209ead
commit b6aa6899a8
7 changed files with 30 additions and 37 deletions

View File

@ -40,8 +40,7 @@ public interface BeanRegistrationAotContribution {
* default code generation isn't suitable.
* @param generationContext the generation context
* @param codeFragments the existing code fragments
* @return the code fragments to use, may be the original instance or a
* wrapper
* @return the code fragments to use, may be the original instance or a wrapper
*/
default BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments(
GenerationContext generationContext, BeanRegistrationCodeFragments codeFragments) {
@ -77,8 +76,7 @@ public interface BeanRegistrationAotContribution {
return defaultCodeFragments.apply(codeFragments);
}
@Override
public void applyTo(GenerationContext generationContext,
BeanRegistrationCode beanRegistrationCode) {
public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) {
}
};
}

View File

@ -31,14 +31,15 @@ import org.springframework.javapoet.CodeBlock;
/**
* Generate the various fragments of code needed to register a bean.
* <p>
* A default implementation is provided that suits most needs and custom code
*
* <p>A default implementation is provided that suits most needs and custom code
* fragments are only expected to be used by library authors having built custom
* arrangement on top of the core container.
* <p>
* Users are not expected to implement this interface directly, but rather extends
* from {@link BeanRegistrationCodeFragmentsDecorator} and only override the
* necessary method(s).
*
* <p>Users are not expected to implement this interface directly, but rather
* extends from {@link BeanRegistrationCodeFragmentsDecorator} and only override
* the necessary method(s).
*
* @author Phillip Webb
* @author Stephane Nicoll
* @since 6.0
@ -48,12 +49,12 @@ import org.springframework.javapoet.CodeBlock;
public interface BeanRegistrationCodeFragments {
/**
* The variable name to used when creating the bean definition.
* The variable name used when creating the bean definition.
*/
String BEAN_DEFINITION_VARIABLE = "beanDefinition";
/**
* The variable name to used when creating the bean definition.
* The variable name used when creating the bean definition.
*/
String INSTANCE_SUPPLIER_VARIABLE = "instanceSupplier";
@ -69,8 +70,7 @@ public interface BeanRegistrationCodeFragments {
/**
* Generate the code that defines the new bean definition instance.
* <p>
* This should declare a variable named {@value BEAN_DEFINITION_VARIABLE}
* <p>This should declare a variable named {@value BEAN_DEFINITION_VARIABLE}
* so that further fragments can refer to the variable to further tune
* the bean definition.
* @param generationContext the generation context
@ -94,14 +94,13 @@ public interface BeanRegistrationCodeFragments {
/**
* Generate the code that sets the instance supplier on the bean definition.
* <p>
* The {@code postProcessors} represent methods to be exposed once the
* <p>The {@code postProcessors} represent methods to be exposed once the
* instance has been created to further configure it. Each method should
* accept two parameters, the {@link RegisteredBean} and the bean
* instance, and should return the modified bean instance.
* @param generationContext the generation context
* @param beanRegistrationCode the bean registration code
* @param instanceSupplierCode the instance supplier code supplier code
* @param instanceSupplierCode the instance supplier code
* @param postProcessors any instance post processors that should be applied
* @return the generated code
* @see #generateInstanceSupplierCode

View File

@ -58,6 +58,7 @@ class BeanRegistrationCodeGenerator implements BeanRegistrationCode {
this.codeFragments = codeFragments;
}
@Override
public ClassName getClassName() {
return this.className;

View File

@ -246,7 +246,7 @@ class DefaultBeanRegistrationCodeFragments implements BeanRegistrationCodeFragme
}
private boolean hasInstanceSupplier() {
return this.registeredBean.getMergedBeanDefinition().getInstanceSupplier() != null;
return (this.registeredBean.getMergedBeanDefinition().getInstanceSupplier() != null);
}
}

View File

@ -31,9 +31,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.lang.Nullable;
/**
* A collection of {@link BeanFactoryInitializationAotContribution AOT
* contributions} obtained from {@link BeanFactoryInitializationAotProcessor AOT
* processors}.
* A collection of {@link BeanFactoryInitializationAotContribution AOT contributions}
* obtained from {@link BeanFactoryInitializationAotProcessor AOT processors}.
*
* @author Phillip Webb
* @since 6.0
@ -47,14 +46,12 @@ class BeanFactoryInitializationAotContributions {
this(beanFactory, AotServices.factoriesAndBeans(beanFactory));
}
BeanFactoryInitializationAotContributions(DefaultListableBeanFactory beanFactory,
AotServices.Loader loader) {
BeanFactoryInitializationAotContributions(DefaultListableBeanFactory beanFactory, AotServices.Loader loader) {
this.contributions = getContributions(beanFactory, getProcessors(loader));
}
private static List<BeanFactoryInitializationAotProcessor> getProcessors(
AotServices.Loader loader) {
private static List<BeanFactoryInitializationAotProcessor> getProcessors(AotServices.Loader loader) {
List<BeanFactoryInitializationAotProcessor> processors = new ArrayList<>(
loader.load(BeanFactoryInitializationAotProcessor.class).asList());
processors.add(new RuntimeHintsBeanFactoryInitializationAotProcessor());
@ -62,8 +59,8 @@ class BeanFactoryInitializationAotContributions {
}
private List<BeanFactoryInitializationAotContribution> getContributions(
DefaultListableBeanFactory beanFactory,
List<BeanFactoryInitializationAotProcessor> processors) {
DefaultListableBeanFactory beanFactory, List<BeanFactoryInitializationAotProcessor> processors) {
List<BeanFactoryInitializationAotContribution> contributions = new ArrayList<>();
for (BeanFactoryInitializationAotProcessor processor : processors) {
BeanFactoryInitializationAotContribution contribution = processAheadOfTime(processor, beanFactory);
@ -75,8 +72,8 @@ class BeanFactoryInitializationAotContributions {
}
@Nullable
private BeanFactoryInitializationAotContribution processAheadOfTime(BeanFactoryInitializationAotProcessor processor,
DefaultListableBeanFactory beanFactory) {
private BeanFactoryInitializationAotContribution processAheadOfTime(
BeanFactoryInitializationAotProcessor processor, DefaultListableBeanFactory beanFactory) {
try {
return processor.processAheadOfTime(beanFactory);
@ -92,6 +89,7 @@ class BeanFactoryInitializationAotContributions {
void applyTo(GenerationContext generationContext,
BeanFactoryInitializationCode beanFactoryInitializationCode) {
for (BeanFactoryInitializationAotContribution contribution : this.contributions) {
contribution.applyTo(generationContext, beanFactoryInitializationCode);
}

View File

@ -40,9 +40,9 @@ public class HibernateQueryException extends InvalidDataAccessResourceUsageExcep
* Return the HQL query string that was invalid.
*/
@Nullable
@SuppressWarnings("NullAway")
public String getQueryString() {
return ((QueryException) getCause()).getQueryString();
QueryException cause = (QueryException) getCause();
return (cause != null ? cause.getQueryString() : null);
}
}

View File

@ -120,7 +120,6 @@ public class LocalSessionFactoryBuilder extends Configuration {
private final ResourcePatternResolver resourcePatternResolver;
@Nullable
private TypeFilter[] entityTypeFilters = DEFAULT_ENTITY_TYPE_FILTERS;
@ -379,13 +378,11 @@ public class LocalSessionFactoryBuilder extends Configuration {
* the current class descriptor contained in the metadata reader.
*/
private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException {
if (this.entityTypeFilters != null) {
for (TypeFilter filter : this.entityTypeFilters) {
if (filter.match(reader, readerFactory)) {
return true;
}
}
}
return false;
}