diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index d8c54764cd2..f0bb35b955b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,16 +121,16 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto implements ConfigurableListableBeanFactory, BeanDefinitionRegistry, Serializable { @Nullable - private static Class javaxInjectProviderClass; + private static Class jakartaInjectProviderClass; static { try { - javaxInjectProviderClass = + jakartaInjectProviderClass = ClassUtils.forName("jakarta.inject.Provider", DefaultListableBeanFactory.class.getClassLoader()); } catch (ClassNotFoundException ex) { // JSR-330 API not available - Provider interface simply not supported then. - javaxInjectProviderClass = null; + jakartaInjectProviderClass = null; } } @@ -1327,7 +1327,7 @@ else if (ObjectFactory.class == descriptor.getDependencyType() || ObjectProvider.class == descriptor.getDependencyType()) { return new DependencyObjectProvider(descriptor, requestingBeanName); } - else if (javaxInjectProviderClass == descriptor.getDependencyType()) { + else if (jakartaInjectProviderClass == descriptor.getDependencyType()) { return new Jsr330Factory().createDependencyProvider(descriptor, requestingBeanName); } else { @@ -1757,7 +1757,7 @@ else if (candidatePriority < highestPriority) { * Return whether the bean definition for the given bean name has been * marked as a primary bean. * @param beanName the name of the bean - * @param beanInstance the corresponding bean instance (can be null) + * @param beanInstance the corresponding bean instance (can be {@code null}) * @return whether the given bean qualifies as primary */ protected boolean isPrimary(String beanName, Object beanInstance) { diff --git a/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java b/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java index 9e5173ab7e6..35a10dfba70 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ /** * Register the necessary reflection hints so that the specified type can be - * bound at runtime. Fields, constructors, properties and record components + * bound at runtime. Fields, constructors, properties, and record components * are registered, except for a set of types like those in the {@code java.} * package where just the type is registered. Types are discovered transitively * on properties and record components, and generic types are registered as well. @@ -54,8 +54,9 @@ public class BindingReflectionHintsRegistrar { private static final String JACKSON_ANNOTATION = "com.fasterxml.jackson.annotation.JacksonAnnotation"; - private static final boolean jacksonAnnotationPresent = ClassUtils.isPresent(JACKSON_ANNOTATION, - BindingReflectionHintsRegistrar.class.getClassLoader()); + private static final boolean jacksonAnnotationPresent = + ClassUtils.isPresent(JACKSON_ANNOTATION, BindingReflectionHintsRegistrar.class.getClassLoader()); + /** * Register the necessary reflection hints to bind the specified types. @@ -94,8 +95,7 @@ private void registerReflectionHints(ReflectionHints hints, Set seen, Type registerRecordHints(hints, seen, recordComponent.getAccessor()); } } - typeHint.withMembers( - MemberCategory.DECLARED_FIELDS, + typeHint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); for (Method method : clazz.getMethods()) { String methodName = method.getName(); @@ -132,8 +132,7 @@ private void registerRecordHints(ReflectionHints hints, Set seen, Method m } private void registerPropertyHints(ReflectionHints hints, Set seen, @Nullable Method method, int parameterIndex) { - if (method != null && method.getDeclaringClass() != Object.class && - method.getDeclaringClass() != Enum.class) { + if (method != null && method.getDeclaringClass() != Object.class && method.getDeclaringClass() != Enum.class) { hints.registerMethod(method, ExecutableMode.INVOKE); MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); Type methodParameterType = methodParameter.getGenericParameterType(); @@ -191,13 +190,13 @@ private void forEachJacksonAnnotation(AnnotatedElement element, Consumer annotation) { - annotation.getRoot().asMap().forEach((key,value) -> { + annotation.getRoot().asMap().forEach((attributeName, value) -> { if (value instanceof Class classValue && value != Void.class) { - if (key.equals("builder")) { + if (attributeName.equals("builder")) { hints.registerType(classValue, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS); } @@ -208,6 +207,7 @@ private void registerHintsForClassAttributes(ReflectionHints hints, MergedAnnota }); } + /** * Inner class to avoid a hard dependency on Kotlin at runtime. */ diff --git a/spring-web/src/main/java/org/springframework/http/CacheControl.java b/spring-web/src/main/java/org/springframework/http/CacheControl.java index 4cb693cf8f9..00b32d8aa48 100644 --- a/spring-web/src/main/java/org/springframework/http/CacheControl.java +++ b/spring-web/src/main/java/org/springframework/http/CacheControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -393,7 +393,7 @@ private String toHeaderValue() { } private void appendDirective(StringBuilder builder, String value) { - if (builder.length() > 0) { + if (!builder.isEmpty()) { builder.append(", "); } builder.append(value);