Skip to content

Commit 7be0aa0

Browse files
committed
Polishing
1 parent e714fc5 commit 7be0aa0

File tree

11 files changed

+112
-126
lines changed

11 files changed

+112
-126
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 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.
@@ -28,32 +28,26 @@
2828
import org.springframework.util.StringValueResolver;
2929

3030
/**
31-
* {@link PlaceholderConfigurerSupport} subclass that resolves ${...} placeholders
32-
* against {@link #setLocation local} {@link #setProperties properties} and/or system properties
31+
* {@link PlaceholderConfigurerSupport} subclass that resolves ${...} placeholders against
32+
* {@link #setLocation local} {@link #setProperties properties} and/or system properties
3333
* and environment variables.
3434
*
3535
* <p>As of Spring 3.1, {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
3636
* PropertySourcesPlaceholderConfigurer} should be used preferentially over this implementation; it is
37-
* more flexible through taking advantage of the {@link org.springframework.core.env.Environment Environment} and
38-
* {@link org.springframework.core.env.PropertySource PropertySource} mechanisms also made available in Spring 3.1.
37+
* more flexible through taking advantage of the {@link org.springframework.core.env.Environment} and
38+
* {@link org.springframework.core.env.PropertySource} mechanisms also made available in Spring 3.1.
3939
*
4040
* <p>{@link PropertyPlaceholderConfigurer} is still appropriate for use when:
4141
* <ul>
4242
* <li>the {@code spring-context} module is not available (i.e., one is using Spring's
4343
* {@code BeanFactory} API as opposed to {@code ApplicationContext}).
44-
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"} and/or
45-
* {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties. Users are encouraged to move
46-
* away from using these settings, and rather configure property source search order through the container's
47-
* {@code Environment}; however, exact preservation of functionality may be maintained by continuing to
48-
* use {@code PropertyPlaceholderConfigurer}.
44+
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"}
45+
* and/or {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties.
46+
* Users are encouraged to move away from using these settings, and rather configure property
47+
* source search order through the container's {@code Environment}; however, exact preservation
48+
* of functionality may be maintained by continuing to use {@code PropertyPlaceholderConfigurer}.
4949
* </ul>
5050
*
51-
* <p>Prior to Spring 3.1, the {@code <context:property-placeholder/>} namespace element
52-
* registered an instance of {@code PropertyPlaceholderConfigurer}. It will still do so if
53-
* using the {@code spring-context-3.0.xsd} definition of the namespace. That is, you can preserve
54-
* registration of {@code PropertyPlaceholderConfigurer} through the namespace, even if using Spring 3.1;
55-
* simply do not update your {@code xsi:schemaLocation} and continue using the 3.0 XSD.
56-
*
5751
* @author Juergen Hoeller
5852
* @author Chris Beams
5953
* @since 02.10.2003
@@ -92,7 +86,6 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
9286
* Set the system property mode by the name of the corresponding constant,
9387
* e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
9488
* @param constantName name of the constant
95-
* @throws java.lang.IllegalArgumentException if an invalid constant was specified
9689
* @see #setSystemPropertiesMode
9790
*/
9891
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException {
@@ -124,14 +117,9 @@ public void setSystemPropertiesMode(int systemPropertiesMode) {
124117
* against system environment variables. Note that it is generally recommended
125118
* to pass external values in as JVM system properties: This can easily be
126119
* achieved in a startup script, even for existing environment variables.
127-
* <p><b>NOTE:</b> Access to environment variables does not work on the
128-
* Sun VM 1.4, where the corresponding {@link System#getenv} support was
129-
* disabled - before it eventually got re-enabled for the Sun VM 1.5.
130-
* Please upgrade to 1.5 (or higher) if you intend to rely on the
131-
* environment variable support.
132120
* @see #setSystemPropertiesMode
133-
* @see java.lang.System#getProperty(String)
134-
* @see java.lang.System#getenv(String)
121+
* @see System#getProperty(String)
122+
* @see System#getenv(String)
135123
*/
136124
public void setSearchSystemEnvironment(boolean searchSystemEnvironment) {
137125
this.searchSystemEnvironment = searchSystemEnvironment;
@@ -264,7 +252,7 @@ public String resolveStringValue(String strVal) throws BeansException {
264252
}
265253

266254

267-
private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
255+
private final class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
268256

269257
private final Properties props;
270258

@@ -274,7 +262,8 @@ private PropertyPlaceholderConfigurerResolver(Properties props) {
274262

275263
@Override
276264
public String resolvePlaceholder(String placeholderName) {
277-
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode);
265+
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName,
266+
this.props, systemPropertiesMode);
278267
}
279268
}
280269

spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 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.
@@ -164,7 +164,7 @@ public static Object resolveAutowiringValue(Object autowiringValue, Class<?> req
164164
* on the given method itself.
165165
* <p>For example, given a factory method with the following signature, if
166166
* {@code resolveReturnTypeForFactoryMethod()} is invoked with the reflected
167-
* method for {@code creatProxy()} and an {@code Object[]} array containing
167+
* method for {@code createProxy()} and an {@code Object[]} array containing
168168
* {@code MyService.class}, {@code resolveReturnTypeForFactoryMethod()} will
169169
* infer that the target return type is {@code MyService}.
170170
* <pre class="code">{@code public static <T> T createProxy(Class<T> clazz)}</pre>

spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 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.
@@ -79,12 +79,13 @@ public boolean matches(Method method) {
7979
return true;
8080
}
8181
// If we get here, we need to insist on precise argument matching...
82-
if (this.typeIdentifiers.size() != method.getParameterTypes().length) {
82+
Class<?>[] parameterTypes = method.getParameterTypes();
83+
if (this.typeIdentifiers.size() != parameterTypes.length) {
8384
return false;
8485
}
8586
for (int i = 0; i < this.typeIdentifiers.size(); i++) {
8687
String identifier = this.typeIdentifiers.get(i);
87-
if (!method.getParameterTypes()[i].getName().contains(identifier)) {
88+
if (!parameterTypes[i].getName().contains(identifier)) {
8889
return false;
8990
}
9091
}

spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -38,7 +38,7 @@ protected DirectFieldAccessor createAccessor(Object target) {
3838

3939

4040
@Test
41-
public void withShadowedField() throws Exception {
41+
public void withShadowedField() {
4242
final StringBuilder sb = new StringBuilder();
4343

4444
@SuppressWarnings("serial")

spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 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.
@@ -20,7 +20,6 @@
2020

2121
import org.aopalliance.intercept.MethodInterceptor;
2222
import org.aopalliance.intercept.MethodInvocation;
23-
2423
import org.junit.Test;
2524

2625
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
@@ -60,7 +59,7 @@ public void testNullConfig() {
6059
}
6160

6261
@Test
63-
public void testProxyIsJustInterface() throws Throwable {
62+
public void testProxyIsJustInterface() {
6463
TestBean raw = new TestBean();
6564
raw.setAge(32);
6665
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
@@ -73,7 +72,7 @@ public void testProxyIsJustInterface() throws Throwable {
7372
}
7473

7574
@Test
76-
public void testInterceptorIsInvokedWithNoTarget() throws Throwable {
75+
public void testInterceptorIsInvokedWithNoTarget() {
7776
// Test return value
7877
final int age = 25;
7978
MethodInterceptor mi = (invocation -> age);
@@ -87,7 +86,7 @@ public void testInterceptorIsInvokedWithNoTarget() throws Throwable {
8786
}
8887

8988
@Test
90-
public void testTargetCanGetInvocationWithPrivateClass() throws Throwable {
89+
public void testTargetCanGetInvocationWithPrivateClass() {
9190
final ExposedInvocationTestBean expectedTarget = new ExposedInvocationTestBean() {
9291
@Override
9392
protected void assertions(MethodInvocation invocation) {
@@ -128,7 +127,7 @@ public void testProxyNotWrappedIfIncompatible() {
128127
}
129128

130129
@Test
131-
public void testEqualsAndHashCodeDefined() throws Exception {
130+
public void testEqualsAndHashCodeDefined() {
132131
AdvisedSupport as = new AdvisedSupport(Named.class);
133132
as.setTarget(new Person());
134133
JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(as);
@@ -139,7 +138,7 @@ public void testEqualsAndHashCodeDefined() throws Exception {
139138
}
140139

141140
@Test // SPR-13328
142-
public void testVarargsWithEnumArray() throws Exception {
141+
public void testVarargsWithEnumArray() {
143142
ProxyFactory proxyFactory = new ProxyFactory(new VarargTestBean());
144143
VarargTestInterface proxy = (VarargTestInterface) proxyFactory.getProxy();
145144
assertTrue(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C));

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

Lines changed: 3 additions & 3 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.
@@ -226,8 +226,8 @@ public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method b
226226
if (bridgeMethod == bridgedMethod) {
227227
return true;
228228
}
229-
return (Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()) &&
230-
bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()));
229+
return (bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()) &&
230+
Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()));
231231
}
232232

233233
}

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

Lines changed: 27 additions & 28 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.
@@ -559,8 +559,8 @@ private boolean isWildcardWithoutBounds() {
559559
}
560560

561561
/**
562-
* Return a {@link ResolvableType} for the specified nesting level. See
563-
* {@link #getNested(int, Map)} for details.
562+
* Return a {@link ResolvableType} for the specified nesting level.
563+
* See {@link #getNested(int, Map)} for details.
564564
* @param nestingLevel the nesting level
565565
* @return the {@link ResolvableType} type, or {@code #NONE}
566566
*/
@@ -569,11 +569,11 @@ public ResolvableType getNested(int nestingLevel) {
569569
}
570570

571571
/**
572-
* Return a {@link ResolvableType} for the specified nesting level. The nesting level
573-
* refers to the specific generic parameter that should be returned. A nesting level
574-
* of 1 indicates this type; 2 indicates the first nested generic; 3 the second; and so
575-
* on. For example, given {@code List<Set<Integer>>} level 1 refers to the
576-
* {@code List}, level 2 the {@code Set}, and level 3 the {@code Integer}.
572+
* Return a {@link ResolvableType} for the specified nesting level.
573+
* <p>The nesting level refers to the specific generic parameter that should be returned.
574+
* A nesting level of 1 indicates this type; 2 indicates the first nested generic;
575+
* 3 the second; and so on. For example, given {@code List<Set<Integer>>} level 1 refers
576+
* to the {@code List}, level 2 the {@code Set}, and level 3 the {@code Integer}.
577577
* <p>The {@code typeIndexesPerLevel} map can be used to reference a specific generic
578578
* for the given level. For example, an index of 0 would refer to a {@code Map} key;
579579
* whereas, 1 would refer to the value. If the map does not contain a value for a
@@ -582,11 +582,11 @@ public ResolvableType getNested(int nestingLevel) {
582582
* {@code String[]}, a nesting level of 2 refers to {@code String}.
583583
* <p>If a type does not {@link #hasGenerics() contain} generics the
584584
* {@link #getSuperType() supertype} hierarchy will be considered.
585-
* @param nestingLevel the required nesting level, indexed from 1 for the current
586-
* type, 2 for the first nested generic, 3 for the second and so on
587-
* @param typeIndexesPerLevel a map containing the generic index for a given nesting
588-
* level (may be {@code null})
589-
* @return a {@link ResolvableType} for the nested level or {@link #NONE}
585+
* @param nestingLevel the required nesting level, indexed from 1 for the
586+
* current type, 2 for the first nested generic, 3 for the second and so on
587+
* @param typeIndexesPerLevel a map containing the generic index for a given
588+
* nesting level (may be {@code null})
589+
* @return a {@link ResolvableType} for the nested level, or {@link #NONE}
590590
*/
591591
public ResolvableType getNested(int nestingLevel, Map<Integer, Integer> typeIndexesPerLevel) {
592592
ResolvableType result = this;
@@ -608,17 +608,17 @@ public ResolvableType getNested(int nestingLevel, Map<Integer, Integer> typeInde
608608
}
609609

610610
/**
611-
* Return a {@link ResolvableType} representing the generic parameter for the given
612-
* indexes. Indexes are zero based; for example given the type
611+
* Return a {@link ResolvableType} representing the generic parameter for the
612+
* given indexes. Indexes are zero based; for example given the type
613613
* {@code Map<Integer, List<String>>}, {@code getGeneric(0)} will access the
614614
* {@code Integer}. Nested generics can be accessed by specifying multiple indexes;
615-
* for example {@code getGeneric(1, 0)} will access the {@code String} from the nested
616-
* {@code List}. For convenience, if no indexes are specified the first generic is
617-
* returned.
615+
* for example {@code getGeneric(1, 0)} will access the {@code String} from the
616+
* nested {@code List}. For convenience, if no indexes are specified the first
617+
* generic is returned.
618618
* <p>If no generic is available at the specified indexes {@link #NONE} is returned.
619-
* @param indexes the indexes that refer to the generic parameter (may be omitted to
620-
* return the first generic)
621-
* @return a {@link ResolvableType} for the specified generic or {@link #NONE}
619+
* @param indexes the indexes that refer to the generic parameter
620+
* (may be omitted to return the first generic)
621+
* @return a {@link ResolvableType} for the specified generic, or {@link #NONE}
622622
* @see #hasGenerics()
623623
* @see #getGenerics()
624624
* @see #resolveGeneric(int...)
@@ -693,9 +693,8 @@ public Class<?>[] resolveGenerics() {
693693
* Convenience method that will {@link #getGenerics() get} and {@link #resolve()
694694
* resolve} generic parameters, using the specified {@code fallback} if any type
695695
* cannot be resolved.
696-
* @param fallback the fallback class to use if resolution fails (may be {@code null})
697-
* @return an array of resolved generic parameters (the resulting array will never be
698-
* {@code null}, but it may contain {@code null} elements})
696+
* @param fallback the fallback class to use if resolution fails
697+
* @return an array of resolved generic parameters
699698
* @see #getGenerics()
700699
* @see #resolve()
701700
*/
@@ -740,7 +739,7 @@ public Class<?> resolve() {
740739
* {@code fallback} if the type cannot be resolved. This method will consider bounds
741740
* of {@link TypeVariable}s and {@link WildcardType}s if direct resolution fails;
742741
* however, bounds of {@code Object.class} will be ignored.
743-
* @param fallback the fallback class to use if resolution fails (may be {@code null})
742+
* @param fallback the fallback class to use if resolution fails
744743
* @return the resolved {@link Class} or the {@code fallback}
745744
* @see #resolve()
746745
* @see #resolveGeneric(int...)
@@ -935,8 +934,8 @@ public static ResolvableType forClass(Class<?> clazz) {
935934
}
936935

937936
/**
938-
* Return a {@link ResolvableType} for the specified {@link Class}, doing
939-
* assignability checks against the raw class only (analogous to
937+
* Return a {@link ResolvableType} for the specified {@link Class},
938+
* doing assignability checks against the raw class only (analogous to
940939
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
941940
* For example: {@code ResolvableType.forRawClass(List.class)}.
942941
* @param clazz the class to introspect ({@code null} is semantically
@@ -1286,7 +1285,7 @@ private static ResolvableType[] forTypes(Type[] types, VariableResolver owner) {
12861285
/**
12871286
* Return a {@link ResolvableType} for the specified {@link Type}.
12881287
* Note: The resulting {@link ResolvableType} may not be {@link Serializable}.
1289-
* @param type the source type or {@code null}
1288+
* @param type the source type (potentially {@code null})
12901289
* @return a {@link ResolvableType} for the specified {@link Type}
12911290
* @see #forType(Type, ResolvableType)
12921291
*/

spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java

Lines changed: 4 additions & 3 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.
@@ -323,7 +323,9 @@ public void writeTo(OutputStream outputStream) throws IOException {
323323
}
324324
}
325325

326-
private void writeMultipart(final MultiValueMap<String, Object> parts, HttpOutputMessage outputMessage) throws IOException {
326+
private void writeMultipart(final MultiValueMap<String, Object> parts, HttpOutputMessage outputMessage)
327+
throws IOException {
328+
327329
final byte[] boundary = generateMultipartBoundary();
328330
Map<String, String> parameters = Collections.singletonMap("boundary", new String(boundary, "US-ASCII"));
329331

@@ -381,7 +383,6 @@ private void writePart(String name, HttpEntity<?> partEntity, OutputStream os) t
381383
"found for request type [" + partType.getName() + "]");
382384
}
383385

384-
385386
/**
386387
* Generate a multipart boundary.
387388
* <p>This implementation delegates to

spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketMessageBrokerStats.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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.
@@ -38,7 +38,7 @@
3838
* {@code @EnableWebSocketMessageBroker} for Java config and
3939
* {@code <websocket:message-broker>} for XML.
4040
*
41-
* <p>By default aggregated information is logged every 15 minutes at INFO level.
41+
* <p>By default aggregated information is logged every 30 minutes at INFO level.
4242
* The frequency of logging can be changed via {@link #setLoggingPeriod(long)}.
4343
*
4444
* <p>This class is declared as a Spring bean by the above configuration with the
@@ -189,7 +189,7 @@ public String toString() {
189189
", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" +
190190
", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" +
191191
", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" +
192-
", outboundChannel" + getClientOutboundExecutorStatsInfo() + "]" +
192+
", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" +
193193
", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]";
194194
}
195195

0 commit comments

Comments
 (0)