Skip to content

Commit e0283c2

Browse files
committed
Polishing
1 parent 183f367 commit e0283c2

File tree

9 files changed

+56
-67
lines changed

9 files changed

+56
-67
lines changed

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

Lines changed: 11 additions & 22 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.
@@ -28,8 +28,8 @@
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
@@ -41,19 +41,13 @@
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,11 +117,6 @@ 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
133121
* @see java.lang.System#getProperty(String)
134122
* @see java.lang.System#getenv(String)
@@ -250,7 +238,7 @@ public String resolveStringValue(String strVal) throws BeansException {
250238
}
251239

252240

253-
private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
241+
private final class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
254242

255243
private final Properties props;
256244

@@ -261,7 +249,8 @@ private PropertyPlaceholderConfigurerResolver(Properties props) {
261249
@Override
262250
@Nullable
263251
public String resolvePlaceholder(String placeholderName) {
264-
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode);
252+
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName,
253+
this.props, systemPropertiesMode);
265254
}
266255
}
267256

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-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.
@@ -158,7 +158,7 @@ public static Object resolveAutowiringValue(Object autowiringValue, Class<?> req
158158
* on the given method itself.
159159
* <p>For example, given a factory method with the following signature, if
160160
* {@code resolveReturnTypeForFactoryMethod()} is invoked with the reflected
161-
* method for {@code creatProxy()} and an {@code Object[]} array containing
161+
* method for {@code createProxy()} and an {@code Object[]} array containing
162162
* {@code MyService.class}, {@code resolveReturnTypeForFactoryMethod()} will
163163
* infer that the target return type is {@code MyService}.
164164
* <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: 3 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.
@@ -82,9 +82,10 @@ public boolean matches(Method method) {
8282
if (this.typeIdentifiers.size() != method.getParameterCount()) {
8383
return false;
8484
}
85+
Class<?>[] parameterTypes = method.getParameterTypes();
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.
@@ -231,8 +231,8 @@ public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method b
231231
if (bridgeMethod == bridgedMethod) {
232232
return true;
233233
}
234-
return (Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()) &&
235-
bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()));
234+
return (bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()) &&
235+
Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()));
236236
}
237237

238238
}

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

Lines changed: 23 additions & 23 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.
@@ -573,8 +573,8 @@ private boolean isWildcardWithoutBounds() {
573573
}
574574

575575
/**
576-
* Return a {@link ResolvableType} for the specified nesting level. See
577-
* {@link #getNested(int, Map)} for details.
576+
* Return a {@link ResolvableType} for the specified nesting level.
577+
* See {@link #getNested(int, Map)} for details.
578578
* @param nestingLevel the nesting level
579579
* @return the {@link ResolvableType} type, or {@code #NONE}
580580
*/
@@ -583,11 +583,11 @@ public ResolvableType getNested(int nestingLevel) {
583583
}
584584

585585
/**
586-
* Return a {@link ResolvableType} for the specified nesting level. The nesting level
587-
* refers to the specific generic parameter that should be returned. A nesting level
588-
* of 1 indicates this type; 2 indicates the first nested generic; 3 the second; and so
589-
* on. For example, given {@code List<Set<Integer>>} level 1 refers to the
590-
* {@code List}, level 2 the {@code Set}, and level 3 the {@code Integer}.
586+
* Return a {@link ResolvableType} for the specified nesting level.
587+
* <p>The nesting level refers to the specific generic parameter that should be returned.
588+
* A nesting level of 1 indicates this type; 2 indicates the first nested generic;
589+
* 3 the second; and so on. For example, given {@code List<Set<Integer>>} level 1 refers
590+
* to the {@code List}, level 2 the {@code Set}, and level 3 the {@code Integer}.
591591
* <p>The {@code typeIndexesPerLevel} map can be used to reference a specific generic
592592
* for the given level. For example, an index of 0 would refer to a {@code Map} key;
593593
* whereas, 1 would refer to the value. If the map does not contain a value for a
@@ -596,11 +596,11 @@ public ResolvableType getNested(int nestingLevel) {
596596
* {@code String[]}, a nesting level of 2 refers to {@code String}.
597597
* <p>If a type does not {@link #hasGenerics() contain} generics the
598598
* {@link #getSuperType() supertype} hierarchy will be considered.
599-
* @param nestingLevel the required nesting level, indexed from 1 for the current
600-
* type, 2 for the first nested generic, 3 for the second and so on
601-
* @param typeIndexesPerLevel a map containing the generic index for a given nesting
602-
* level (may be {@code null})
603-
* @return a {@link ResolvableType} for the nested level or {@link #NONE}
599+
* @param nestingLevel the required nesting level, indexed from 1 for the
600+
* current type, 2 for the first nested generic, 3 for the second and so on
601+
* @param typeIndexesPerLevel a map containing the generic index for a given
602+
* nesting level (may be {@code null})
603+
* @return a {@link ResolvableType} for the nested level, or {@link #NONE}
604604
*/
605605
public ResolvableType getNested(int nestingLevel, @Nullable Map<Integer, Integer> typeIndexesPerLevel) {
606606
ResolvableType result = this;
@@ -622,17 +622,17 @@ public ResolvableType getNested(int nestingLevel, @Nullable Map<Integer, Integer
622622
}
623623

624624
/**
625-
* Return a {@link ResolvableType} representing the generic parameter for the given
626-
* indexes. Indexes are zero based; for example given the type
625+
* Return a {@link ResolvableType} representing the generic parameter for the
626+
* given indexes. Indexes are zero based; for example given the type
627627
* {@code Map<Integer, List<String>>}, {@code getGeneric(0)} will access the
628628
* {@code Integer}. Nested generics can be accessed by specifying multiple indexes;
629-
* for example {@code getGeneric(1, 0)} will access the {@code String} from the nested
630-
* {@code List}. For convenience, if no indexes are specified the first generic is
631-
* returned.
629+
* for example {@code getGeneric(1, 0)} will access the {@code String} from the
630+
* nested {@code List}. For convenience, if no indexes are specified the first
631+
* generic is returned.
632632
* <p>If no generic is available at the specified indexes {@link #NONE} is returned.
633-
* @param indexes the indexes that refer to the generic parameter (may be omitted to
634-
* return the first generic)
635-
* @return a {@link ResolvableType} for the specified generic or {@link #NONE}
633+
* @param indexes the indexes that refer to the generic parameter
634+
* (may be omitted to return the first generic)
635+
* @return a {@link ResolvableType} for the specified generic, or {@link #NONE}
636636
* @see #hasGenerics()
637637
* @see #getGenerics()
638638
* @see #resolveGeneric(int...)
@@ -968,8 +968,8 @@ public static ResolvableType forClass(@Nullable Class<?> clazz) {
968968
}
969969

970970
/**
971-
* Return a {@link ResolvableType} for the specified {@link Class}, doing
972-
* assignability checks against the raw class only (analogous to
971+
* Return a {@link ResolvableType} for the specified {@link Class},
972+
* doing assignability checks against the raw class only (analogous to
973973
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
974974
* For example: {@code ResolvableType.forRawClass(List.class)}.
975975
* @param clazz the class to introspect ({@code null} is semantically

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

Lines changed: 4 additions & 4 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.
@@ -340,15 +340,15 @@ else if (mediaType.getCharset() == null) {
340340
}
341341
}
342342

343-
private void writeMultipart(final MultiValueMap<String, Object> parts,
344-
HttpOutputMessage outputMessage) throws IOException {
343+
private void writeMultipart(final MultiValueMap<String, Object> parts, HttpOutputMessage outputMessage)
344+
throws IOException {
345345

346346
final byte[] boundary = generateMultipartBoundary();
347347
Map<String, String> parameters = new LinkedHashMap<>(2);
348348
if (!isFilenameCharsetSet()) {
349349
parameters.put("charset", this.charset.name());
350350
}
351-
parameters.put("boundary", new String(boundary, "US-ASCII"));
351+
parameters.put("boundary", new String(boundary, StandardCharsets.US_ASCII));
352352

353353
MediaType contentType = new MediaType(MediaType.MULTIPART_FORM_DATA, parameters);
354354
HttpHeaders headers = outputMessage.getHeaders();

spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketMessageBrokerStats.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.
@@ -199,7 +199,7 @@ public String toString() {
199199
", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" +
200200
", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" +
201201
", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" +
202-
", outboundChannel" + getClientOutboundExecutorStatsInfo() + "]" +
202+
", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" +
203203
", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]";
204204
}
205205

0 commit comments

Comments
 (0)