Skip to content

Commit 6f0461c

Browse files
committed
Polishing
1 parent 04df9b8 commit 6f0461c

File tree

5 files changed

+22
-31
lines changed

5 files changed

+22
-31
lines changed

spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ public Object lookup(String lookupName) throws NameNotFoundException {
126126
if (logger.isDebugEnabled()) {
127127
logger.debug("Static JNDI lookup: [" + name + "]");
128128
}
129-
if ("".equals(name)) {
129+
if (name.isEmpty()) {
130130
return new SimpleNamingContext(this.root, this.boundObjects, this.environment);
131131
}
132132
Object found = this.boundObjects.get(name);
@@ -303,10 +303,10 @@ public Name composeName(Name name, Name prefix) throws NamingException {
303303

304304
private abstract static class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
305305

306-
private Iterator<T> iterator;
306+
private final Iterator<T> iterator;
307307

308308
private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
309-
if (!"".equals(proot) && !proot.endsWith("/")) {
309+
if (!proot.isEmpty() && !proot.endsWith("/")) {
310310
proot = proot + "/";
311311
}
312312
String root = context.root + proot;

spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -303,7 +303,7 @@ public Name composeName(Name name, Name prefix) throws NamingException {
303303

304304
private abstract static class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
305305

306-
private Iterator<T> iterator;
306+
private final Iterator<T> iterator;
307307

308308
private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
309309
if (!proot.isEmpty() && !proot.endsWith("/")) {

spring-test/src/main/java/org/springframework/test/context/support/AbstractGenericContextLoader.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
6464

6565
/**
6666
* Load a Spring ApplicationContext from the supplied {@link MergedContextConfiguration}.
67-
*
6867
* <p>Implementation details:
69-
*
7068
* <ul>
7169
* <li>Calls {@link #validateMergedContextConfiguration(MergedContextConfiguration)}
7270
* to allow subclasses to validate the supplied configuration before proceeding.</li>
@@ -98,7 +96,6 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
9896
* <li>{@link ConfigurableApplicationContext#refresh Refreshes} the
9997
* context and registers a JVM shutdown hook for it.</li>
10098
* </ul>
101-
*
10299
* @return a new application context
103100
* @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration)
104101
* @see GenericApplicationContext
@@ -108,26 +105,28 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
108105
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
109106
if (logger.isDebugEnabled()) {
110107
logger.debug(String.format("Loading ApplicationContext for merged context configuration [%s].",
111-
mergedConfig));
108+
mergedConfig));
112109
}
113110

114111
validateMergedContextConfiguration(mergedConfig);
115112

116113
GenericApplicationContext context = createContext();
117-
118114
ApplicationContext parent = mergedConfig.getParentApplicationContext();
119115
if (parent != null) {
120116
context.setParent(parent);
121117
}
118+
122119
prepareContext(context);
123120
prepareContext(context, mergedConfig);
124121
customizeBeanFactory(context.getDefaultListableBeanFactory());
125122
loadBeanDefinitions(context, mergedConfig);
126123
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
127124
customizeContext(context);
128125
customizeContext(context, mergedConfig);
126+
129127
context.refresh();
130128
context.registerShutdownHook();
129+
131130
return context;
132131
}
133132

@@ -147,9 +146,7 @@ protected void validateMergedContextConfiguration(MergedContextConfiguration mer
147146

148147
/**
149148
* Load a Spring ApplicationContext from the supplied {@code locations}.
150-
*
151149
* <p>Implementation details:
152-
*
153150
* <ul>
154151
* <li>Calls {@link #createContext()} to create a {@link GenericApplicationContext}
155152
* instance.</li>
@@ -168,12 +165,10 @@ protected void validateMergedContextConfiguration(MergedContextConfiguration mer
168165
* <li>{@link ConfigurableApplicationContext#refresh Refreshes} the
169166
* context and registers a JVM shutdown hook for it.</li>
170167
* </ul>
171-
*
172168
* <p><b>Note</b>: this method does not provide a means to set active bean definition
173169
* profiles for the loaded context. See {@link #loadContext(MergedContextConfiguration)}
174170
* and {@link AbstractContextLoader#prepareContext(ConfigurableApplicationContext, MergedContextConfiguration)}
175171
* for an alternative.
176-
*
177172
* @return a new application context
178173
* @see org.springframework.test.context.ContextLoader#loadContext
179174
* @see GenericApplicationContext
@@ -184,28 +179,30 @@ protected void validateMergedContextConfiguration(MergedContextConfiguration mer
184179
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {
185180
if (logger.isDebugEnabled()) {
186181
logger.debug(String.format("Loading ApplicationContext for locations [%s].",
187-
StringUtils.arrayToCommaDelimitedString(locations)));
182+
StringUtils.arrayToCommaDelimitedString(locations)));
188183
}
184+
189185
GenericApplicationContext context = createContext();
186+
190187
prepareContext(context);
191188
customizeBeanFactory(context.getDefaultListableBeanFactory());
192189
createBeanDefinitionReader(context).loadBeanDefinitions(locations);
193190
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
194191
customizeContext(context);
192+
195193
context.refresh();
196194
context.registerShutdownHook();
195+
197196
return context;
198197
}
199198

200199
/**
201200
* Factory method for creating the {@link GenericApplicationContext} used by
202201
* this {@code ContextLoader}.
203-
*
204202
* <p>The default implementation creates a {@code GenericApplicationContext}
205203
* using the default constructor. This method may be overridden in subclasses
206204
* &mdash; for example, to create a {@code GenericApplicationContext} with
207205
* a custom {@link DefaultListableBeanFactory} implementation.
208-
*
209206
* @return a newly instantiated {@code GenericApplicationContext}
210207
* @since 5.2.9
211208
*/
@@ -216,10 +213,8 @@ protected GenericApplicationContext createContext() {
216213
/**
217214
* Prepare the {@link GenericApplicationContext} created by this {@code ContextLoader}.
218215
* Called <i>before</i> bean definitions are read.
219-
*
220216
* <p>The default implementation is empty. Can be overridden in subclasses to
221217
* customize {@code GenericApplicationContext}'s standard settings.
222-
*
223218
* @param context the context that should be prepared
224219
* @since 2.5
225220
* @see #loadContext(MergedContextConfiguration)
@@ -235,10 +230,8 @@ protected void prepareContext(GenericApplicationContext context) {
235230
/**
236231
* Customize the internal bean factory of the ApplicationContext created by
237232
* this {@code ContextLoader}.
238-
*
239233
* <p>The default implementation is empty but can be overridden in subclasses
240234
* to customize {@code DefaultListableBeanFactory}'s standard settings.
241-
*
242235
* @param beanFactory the bean factory created by this {@code ContextLoader}
243236
* @since 2.5
244237
* @see #loadContext(MergedContextConfiguration)
@@ -254,18 +247,15 @@ protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
254247
/**
255248
* Load bean definitions into the supplied {@link GenericApplicationContext context}
256249
* from the locations or classes in the supplied {@code MergedContextConfiguration}.
257-
*
258250
* <p>The default implementation delegates to the {@link BeanDefinitionReader}
259251
* returned by {@link #createBeanDefinitionReader(GenericApplicationContext)} to
260252
* {@link BeanDefinitionReader#loadBeanDefinitions(String) load} the
261253
* bean definitions.
262-
*
263254
* <p>Subclasses must provide an appropriate implementation of
264255
* {@link #createBeanDefinitionReader(GenericApplicationContext)}. Alternatively subclasses
265256
* may provide a <em>no-op</em> implementation of {@code createBeanDefinitionReader()}
266257
* and override this method to provide a custom strategy for loading or
267258
* registering bean definitions.
268-
*
269259
* @param context the context into which the bean definitions should be loaded
270260
* @param mergedConfig the merged context configuration
271261
* @since 3.1
@@ -278,7 +268,6 @@ protected void loadBeanDefinitions(GenericApplicationContext context, MergedCont
278268
/**
279269
* Factory method for creating a new {@link BeanDefinitionReader} for loading
280270
* bean definitions into the supplied {@link GenericApplicationContext context}.
281-
*
282271
* @param context the context for which the {@code BeanDefinitionReader}
283272
* should be created
284273
* @return a {@code BeanDefinitionReader} for the supplied context
@@ -293,10 +282,8 @@ protected void loadBeanDefinitions(GenericApplicationContext context, MergedCont
293282
* Customize the {@link GenericApplicationContext} created by this
294283
* {@code ContextLoader} <i>after</i> bean definitions have been
295284
* loaded into the context but <i>before</i> the context is refreshed.
296-
*
297285
* <p>The default implementation is empty but can be overridden in subclasses
298286
* to customize the application context.
299-
*
300287
* @param context the newly created application context
301288
* @since 2.5
302289
* @see #loadContext(MergedContextConfiguration)

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ToStringVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public void unknown(RouterFunction<?> routerFunction) {
7676
}
7777

7878
private void indent() {
79-
for (int i=0; i < this.indent; i++) {
79+
for (int i = 0; i < this.indent; i++) {
8080
this.builder.append(' ');
8181
}
8282
}

spring-webmvc/src/main/java/org/springframework/web/servlet/function/ToStringVisitor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ToStringVisitor implements RouterFunctions.Visitor, RequestPredicates.Visi
3838

3939

4040
// RouterFunctions.Visitor
41+
4142
@Override
4243
public void startNested(RequestPredicate predicate) {
4344
indent();
@@ -74,11 +75,12 @@ public void unknown(RouterFunction<?> routerFunction) {
7475
}
7576

7677
private void indent() {
77-
for (int i=0; i < this.indent; i++) {
78+
for (int i = 0; i < this.indent; i++) {
7879
this.builder.append(' ');
7980
}
8081
}
8182

83+
8284
// RequestPredicates.Visitor
8385

8486
@Override
@@ -156,6 +158,7 @@ public void endNegate() {
156158
public void unknown(RequestPredicate predicate) {
157159
this.builder.append(predicate);
158160
}
161+
159162
@Override
160163
public String toString() {
161164
String result = this.builder.toString();
@@ -164,4 +167,5 @@ public String toString() {
164167
}
165168
return result;
166169
}
170+
167171
}

0 commit comments

Comments
 (0)