diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 6d72e89e3c..af1ca45604 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -231,11 +231,7 @@ class ConfigurationClassParser { // Explicit bean definition found, probably replacing an import. // Let's remove the old one and go with the new one. this.configurationClasses.remove(configClass); - for (Iterator it = this.knownSuperclasses.values().iterator(); it.hasNext();) { - if (configClass.equals(it.next())) { - it.remove(); - } - } + this.knownSuperclasses.values().removeIf(configClass::equals); } } diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java index 415df656c0..a05aff87ab 100644 --- a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java @@ -104,31 +104,6 @@ public class ReactiveAdapterRegistry { } - /** - * Return a shared default {@code ReactiveAdapterRegistry} instance, lazily - * building it once needed. - *

NOTE: We highly recommend passing a long-lived, pre-configured - * {@code ReactiveAdapterRegistry} instance for customization purposes. - * This accessor is only meant as a fallback for code paths that want to - * fall back on a default instance if one isn't provided. - * @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null}) - * @since 5.0.2 - */ - public static ReactiveAdapterRegistry getSharedInstance() { - ReactiveAdapterRegistry ar = sharedInstance; - if (ar == null) { - synchronized (ReactiveAdapterRegistry.class) { - ar = sharedInstance; - if (ar == null) { - ar = new ReactiveAdapterRegistry(); - sharedInstance = ar; - } - } - } - return ar; - } - - /** * Whether the registry has any adapters which would be the case if any of * Reactor, RxJava 2, or RxJava 1 (+ RxJava Reactive Streams bridge) are @@ -138,7 +113,6 @@ public class ReactiveAdapterRegistry { return !this.adapters.isEmpty(); } - /** * Register a reactive type along with functions to adapt to and from a * Reactive Streams {@link Publisher}. The functions can assume their @@ -190,6 +164,31 @@ public class ReactiveAdapterRegistry { } + /** + * Return a shared default {@code ReactiveAdapterRegistry} instance, lazily + * building it once needed. + *

NOTE: We highly recommend passing a long-lived, pre-configured + * {@code ReactiveAdapterRegistry} instance for customization purposes. + * This accessor is only meant as a fallback for code paths that want to + * fall back on a default instance if one isn't provided. + * @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null}) + * @since 5.0.2 + */ + public static ReactiveAdapterRegistry getSharedInstance() { + ReactiveAdapterRegistry ar = sharedInstance; + if (ar == null) { + synchronized (ReactiveAdapterRegistry.class) { + ar = sharedInstance; + if (ar == null) { + ar = new ReactiveAdapterRegistry(); + sharedInstance = ar; + } + } + } + return ar; + } + + private static class ReactorRegistrar { void registerAdapters(ReactiveAdapterRegistry registry) { diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java index 101f99b44a..e9797987c4 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java @@ -44,6 +44,15 @@ public class DefaultConversionService extends GenericConversionService { private static volatile DefaultConversionService sharedInstance; + /** + * Create a new {@code DefaultConversionService} with the set of + * {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}. + */ + public DefaultConversionService() { + addDefaultConverters(this); + } + + /** * Return a shared default {@code ConversionService} instance, * lazily building it once needed. @@ -69,18 +78,6 @@ public class DefaultConversionService extends GenericConversionService { return cs; } - - /** - * Create a new {@code DefaultConversionService} with the set of - * {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}. - */ - public DefaultConversionService() { - addDefaultConverters(this); - } - - - // static utility methods - /** * Add converters appropriate for most environments. * @param converterRegistry the registry of converters to add to (must also be castable to ConversionService, @@ -134,9 +131,6 @@ public class DefaultConversionService extends GenericConversionService { converterRegistry.addConverter(new StreamConverter(conversionService)); } - - // internal helpers - private static void addScalarConverters(ConverterRegistry converterRegistry) { converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());