Skip to content

Commit 5843173

Browse files
committed
Polishing
1 parent 08c95fb commit 5843173

File tree

3 files changed

+35
-46
lines changed

3 files changed

+35
-46
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,7 @@ protected void processConfigurationClass(ConfigurationClass configClass) throws
231231
// Explicit bean definition found, probably replacing an import.
232232
// Let's remove the old one and go with the new one.
233233
this.configurationClasses.remove(configClass);
234-
for (Iterator<ConfigurationClass> it = this.knownSuperclasses.values().iterator(); it.hasNext();) {
235-
if (configClass.equals(it.next())) {
236-
it.remove();
237-
}
238-
}
234+
this.knownSuperclasses.values().removeIf(configClass::equals);
239235
}
240236
}
241237

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,6 @@ public ReactiveAdapterRegistry() {
104104
}
105105

106106

107-
/**
108-
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
109-
* building it once needed.
110-
* <p><b>NOTE:</b> We highly recommend passing a long-lived, pre-configured
111-
* {@code ReactiveAdapterRegistry} instance for customization purposes.
112-
* This accessor is only meant as a fallback for code paths that want to
113-
* fall back on a default instance if one isn't provided.
114-
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
115-
* @since 5.0.2
116-
*/
117-
public static ReactiveAdapterRegistry getSharedInstance() {
118-
ReactiveAdapterRegistry ar = sharedInstance;
119-
if (ar == null) {
120-
synchronized (ReactiveAdapterRegistry.class) {
121-
ar = sharedInstance;
122-
if (ar == null) {
123-
ar = new ReactiveAdapterRegistry();
124-
sharedInstance = ar;
125-
}
126-
}
127-
}
128-
return ar;
129-
}
130-
131-
132107
/**
133108
* Whether the registry has any adapters which would be the case if any of
134109
* Reactor, RxJava 2, or RxJava 1 (+ RxJava Reactive Streams bridge) are
@@ -138,7 +113,6 @@ public boolean hasAdapters() {
138113
return !this.adapters.isEmpty();
139114
}
140115

141-
142116
/**
143117
* Register a reactive type along with functions to adapt to and from a
144118
* Reactive Streams {@link Publisher}. The functions can assume their
@@ -190,6 +164,31 @@ public ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, @Nullable Obj
190164
}
191165

192166

167+
/**
168+
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
169+
* building it once needed.
170+
* <p><b>NOTE:</b> We highly recommend passing a long-lived, pre-configured
171+
* {@code ReactiveAdapterRegistry} instance for customization purposes.
172+
* This accessor is only meant as a fallback for code paths that want to
173+
* fall back on a default instance if one isn't provided.
174+
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
175+
* @since 5.0.2
176+
*/
177+
public static ReactiveAdapterRegistry getSharedInstance() {
178+
ReactiveAdapterRegistry ar = sharedInstance;
179+
if (ar == null) {
180+
synchronized (ReactiveAdapterRegistry.class) {
181+
ar = sharedInstance;
182+
if (ar == null) {
183+
ar = new ReactiveAdapterRegistry();
184+
sharedInstance = ar;
185+
}
186+
}
187+
}
188+
return ar;
189+
}
190+
191+
193192
private static class ReactorRegistrar {
194193

195194
void registerAdapters(ReactiveAdapterRegistry registry) {

spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ public class DefaultConversionService extends GenericConversionService {
4444
private static volatile DefaultConversionService sharedInstance;
4545

4646

47+
/**
48+
* Create a new {@code DefaultConversionService} with the set of
49+
* {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}.
50+
*/
51+
public DefaultConversionService() {
52+
addDefaultConverters(this);
53+
}
54+
55+
4756
/**
4857
* Return a shared default {@code ConversionService} instance,
4958
* lazily building it once needed.
@@ -69,18 +78,6 @@ public static ConversionService getSharedInstance() {
6978
return cs;
7079
}
7180

72-
73-
/**
74-
* Create a new {@code DefaultConversionService} with the set of
75-
* {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}.
76-
*/
77-
public DefaultConversionService() {
78-
addDefaultConverters(this);
79-
}
80-
81-
82-
// static utility methods
83-
8481
/**
8582
* Add converters appropriate for most environments.
8683
* @param converterRegistry the registry of converters to add to (must also be castable to ConversionService,
@@ -134,9 +131,6 @@ public static void addCollectionConverters(ConverterRegistry converterRegistry)
134131
converterRegistry.addConverter(new StreamConverter(conversionService));
135132
}
136133

137-
138-
// internal helpers
139-
140134
private static void addScalarConverters(ConverterRegistry converterRegistry) {
141135
converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());
142136

0 commit comments

Comments
 (0)