Browse Source

Polishing

pull/23430/head
Juergen Hoeller 7 years ago
parent
commit
e0283c2edf
  1. 33
      spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java
  2. 4
      spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java
  3. 5
      spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
  4. 4
      spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java
  5. 13
      spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java
  6. 6
      spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java
  7. 46
      spring-core/src/main/java/org/springframework/core/ResolvableType.java
  8. 8
      spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
  9. 4
      spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketMessageBrokerStats.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,8 +28,8 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; @@ -28,8 +28,8 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
import org.springframework.util.StringValueResolver;
/**
* {@link PlaceholderConfigurerSupport} subclass that resolves ${...} placeholders
* against {@link #setLocation local} {@link #setProperties properties} and/or system properties
* {@link PlaceholderConfigurerSupport} subclass that resolves ${...} placeholders against
* {@link #setLocation local} {@link #setProperties properties} and/or system properties
* and environment variables.
*
* <p>As of Spring 3.1, {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
@ -41,19 +41,13 @@ import org.springframework.util.StringValueResolver; @@ -41,19 +41,13 @@ import org.springframework.util.StringValueResolver;
* <ul>
* <li>the {@code spring-context} module is not available (i.e., one is using Spring's
* {@code BeanFactory} API as opposed to {@code ApplicationContext}).
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"} and/or
* {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties. Users are encouraged to move
* away from using these settings, and rather configure property source search order through the container's
* {@code Environment}; however, exact preservation of functionality may be maintained by continuing to
* use {@code PropertyPlaceholderConfigurer}.
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"}
* and/or {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties.
* Users are encouraged to move away from using these settings, and rather configure property
* source search order through the container's {@code Environment}; however, exact preservation
* of functionality may be maintained by continuing to use {@code PropertyPlaceholderConfigurer}.
* </ul>
*
* <p>Prior to Spring 3.1, the {@code <context:property-placeholder/>} namespace element
* registered an instance of {@code PropertyPlaceholderConfigurer}. It will still do so if
* using the {@code spring-context-3.0.xsd} definition of the namespace. That is, you can preserve
* registration of {@code PropertyPlaceholderConfigurer} through the namespace, even if using Spring 3.1;
* simply do not update your {@code xsi:schemaLocation} and continue using the 3.0 XSD.
*
* @author Juergen Hoeller
* @author Chris Beams
* @since 02.10.2003
@ -92,7 +86,6 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport @@ -92,7 +86,6 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
* Set the system property mode by the name of the corresponding constant,
* e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
* @param constantName name of the constant
* @throws java.lang.IllegalArgumentException if an invalid constant was specified
* @see #setSystemPropertiesMode
*/
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException {
@ -124,11 +117,6 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport @@ -124,11 +117,6 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
* against system environment variables. Note that it is generally recommended
* to pass external values in as JVM system properties: This can easily be
* achieved in a startup script, even for existing environment variables.
* <p><b>NOTE:</b> Access to environment variables does not work on the
* Sun VM 1.4, where the corresponding {@link System#getenv} support was
* disabled - before it eventually got re-enabled for the Sun VM 1.5.
* Please upgrade to 1.5 (or higher) if you intend to rely on the
* environment variable support.
* @see #setSystemPropertiesMode
* @see java.lang.System#getProperty(String)
* @see java.lang.System#getenv(String)
@ -250,7 +238,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport @@ -250,7 +238,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
}
private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
private final class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
private final Properties props;
@ -261,7 +249,8 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport @@ -261,7 +249,8 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
@Override
@Nullable
public String resolvePlaceholder(String placeholderName) {
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode);
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName,
this.props, systemPropertiesMode);
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -158,7 +158,7 @@ abstract class AutowireUtils { @@ -158,7 +158,7 @@ abstract class AutowireUtils {
* on the given method itself.
* <p>For example, given a factory method with the following signature, if
* {@code resolveReturnTypeForFactoryMethod()} is invoked with the reflected
* method for {@code creatProxy()} and an {@code Object[]} array containing
* method for {@code createProxy()} and an {@code Object[]} array containing
* {@code MyService.class}, {@code resolveReturnTypeForFactoryMethod()} will
* infer that the target return type is {@code MyService}.
* <pre class="code">{@code public static <T> T createProxy(Class<T> clazz)}</pre>

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -82,9 +82,10 @@ public class ReplaceOverride extends MethodOverride { @@ -82,9 +82,10 @@ public class ReplaceOverride extends MethodOverride {
if (this.typeIdentifiers.size() != method.getParameterCount()) {
return false;
}
Class<?>[] parameterTypes = method.getParameterTypes();
for (int i = 0; i < this.typeIdentifiers.size(); i++) {
String identifier = this.typeIdentifiers.get(i);
if (!method.getParameterTypes()[i].getName().contains(identifier)) {
if (!parameterTypes[i].getName().contains(identifier)) {
return false;
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ public class DirectFieldAccessorTests extends AbstractPropertyAccessorTests { @@ -38,7 +38,7 @@ public class DirectFieldAccessorTests extends AbstractPropertyAccessorTests {
@Test
public void withShadowedField() throws Exception {
public void withShadowedField() {
final StringBuilder sb = new StringBuilder();
@SuppressWarnings("serial")

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import java.io.Serializable; @@ -20,7 +20,6 @@ import java.io.Serializable;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
@ -60,7 +59,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -60,7 +59,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testProxyIsJustInterface() throws Throwable {
public void testProxyIsJustInterface() {
TestBean raw = new TestBean();
raw.setAge(32);
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
@ -73,7 +72,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -73,7 +72,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testInterceptorIsInvokedWithNoTarget() throws Throwable {
public void testInterceptorIsInvokedWithNoTarget() {
// Test return value
final int age = 25;
MethodInterceptor mi = (invocation -> age);
@ -87,7 +86,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -87,7 +86,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testTargetCanGetInvocationWithPrivateClass() throws Throwable {
public void testTargetCanGetInvocationWithPrivateClass() {
final ExposedInvocationTestBean expectedTarget = new ExposedInvocationTestBean() {
@Override
protected void assertions(MethodInvocation invocation) {
@ -128,7 +127,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -128,7 +127,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testEqualsAndHashCodeDefined() throws Exception {
public void testEqualsAndHashCodeDefined() {
AdvisedSupport as = new AdvisedSupport(Named.class);
as.setTarget(new Person());
JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(as);
@ -139,7 +138,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -139,7 +138,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test // SPR-13328
public void testVarargsWithEnumArray() throws Exception {
public void testVarargsWithEnumArray() {
ProxyFactory proxyFactory = new ProxyFactory(new VarargTestBean());
VarargTestInterface proxy = (VarargTestInterface) proxyFactory.getProxy();
assertTrue(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C));

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -231,8 +231,8 @@ public abstract class BridgeMethodResolver { @@ -231,8 +231,8 @@ public abstract class BridgeMethodResolver {
if (bridgeMethod == bridgedMethod) {
return true;
}
return (Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()) &&
bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()));
return (bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()) &&
Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()));
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -573,8 +573,8 @@ public class ResolvableType implements Serializable { @@ -573,8 +573,8 @@ public class ResolvableType implements Serializable {
}
/**
* Return a {@link ResolvableType} for the specified nesting level. See
* {@link #getNested(int, Map)} for details.
* Return a {@link ResolvableType} for the specified nesting level.
* See {@link #getNested(int, Map)} for details.
* @param nestingLevel the nesting level
* @return the {@link ResolvableType} type, or {@code #NONE}
*/
@ -583,11 +583,11 @@ public class ResolvableType implements Serializable { @@ -583,11 +583,11 @@ public class ResolvableType implements Serializable {
}
/**
* Return a {@link ResolvableType} for the specified nesting level. The nesting level
* refers to the specific generic parameter that should be returned. A nesting level
* of 1 indicates this type; 2 indicates the first nested generic; 3 the second; and so
* on. For example, given {@code List<Set<Integer>>} level 1 refers to the
* {@code List}, level 2 the {@code Set}, and level 3 the {@code Integer}.
* Return a {@link ResolvableType} for the specified nesting level.
* <p>The nesting level refers to the specific generic parameter that should be returned.
* A nesting level of 1 indicates this type; 2 indicates the first nested generic;
* 3 the second; and so on. For example, given {@code List<Set<Integer>>} level 1 refers
* to the {@code List}, level 2 the {@code Set}, and level 3 the {@code Integer}.
* <p>The {@code typeIndexesPerLevel} map can be used to reference a specific generic
* for the given level. For example, an index of 0 would refer to a {@code Map} key;
* whereas, 1 would refer to the value. If the map does not contain a value for a
@ -596,11 +596,11 @@ public class ResolvableType implements Serializable { @@ -596,11 +596,11 @@ public class ResolvableType implements Serializable {
* {@code String[]}, a nesting level of 2 refers to {@code String}.
* <p>If a type does not {@link #hasGenerics() contain} generics the
* {@link #getSuperType() supertype} hierarchy will be considered.
* @param nestingLevel the required nesting level, indexed from 1 for the current
* type, 2 for the first nested generic, 3 for the second and so on
* @param typeIndexesPerLevel a map containing the generic index for a given nesting
* level (may be {@code null})
* @return a {@link ResolvableType} for the nested level or {@link #NONE}
* @param nestingLevel the required nesting level, indexed from 1 for the
* current type, 2 for the first nested generic, 3 for the second and so on
* @param typeIndexesPerLevel a map containing the generic index for a given
* nesting level (may be {@code null})
* @return a {@link ResolvableType} for the nested level, or {@link #NONE}
*/
public ResolvableType getNested(int nestingLevel, @Nullable Map<Integer, Integer> typeIndexesPerLevel) {
ResolvableType result = this;
@ -622,17 +622,17 @@ public class ResolvableType implements Serializable { @@ -622,17 +622,17 @@ public class ResolvableType implements Serializable {
}
/**
* Return a {@link ResolvableType} representing the generic parameter for the given
* indexes. Indexes are zero based; for example given the type
* Return a {@link ResolvableType} representing the generic parameter for the
* given indexes. Indexes are zero based; for example given the type
* {@code Map<Integer, List<String>>}, {@code getGeneric(0)} will access the
* {@code Integer}. Nested generics can be accessed by specifying multiple indexes;
* for example {@code getGeneric(1, 0)} will access the {@code String} from the nested
* {@code List}. For convenience, if no indexes are specified the first generic is
* returned.
* for example {@code getGeneric(1, 0)} will access the {@code String} from the
* nested {@code List}. For convenience, if no indexes are specified the first
* generic is returned.
* <p>If no generic is available at the specified indexes {@link #NONE} is returned.
* @param indexes the indexes that refer to the generic parameter (may be omitted to
* return the first generic)
* @return a {@link ResolvableType} for the specified generic or {@link #NONE}
* @param indexes the indexes that refer to the generic parameter
* (may be omitted to return the first generic)
* @return a {@link ResolvableType} for the specified generic, or {@link #NONE}
* @see #hasGenerics()
* @see #getGenerics()
* @see #resolveGeneric(int...)
@ -968,8 +968,8 @@ public class ResolvableType implements Serializable { @@ -968,8 +968,8 @@ public class ResolvableType implements Serializable {
}
/**
* Return a {@link ResolvableType} for the specified {@link Class}, doing
* assignability checks against the raw class only (analogous to
* Return a {@link ResolvableType} for the specified {@link Class},
* doing assignability checks against the raw class only (analogous to
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
* For example: {@code ResolvableType.forRawClass(List.class)}.
* @param clazz the class to introspect ({@code null} is semantically

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -340,15 +340,15 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue @@ -340,15 +340,15 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
}
}
private void writeMultipart(final MultiValueMap<String, Object> parts,
HttpOutputMessage outputMessage) throws IOException {
private void writeMultipart(final MultiValueMap<String, Object> parts, HttpOutputMessage outputMessage)
throws IOException {
final byte[] boundary = generateMultipartBoundary();
Map<String, String> parameters = new LinkedHashMap<>(2);
if (!isFilenameCharsetSet()) {
parameters.put("charset", this.charset.name());
}
parameters.put("boundary", new String(boundary, "US-ASCII"));
parameters.put("boundary", new String(boundary, StandardCharsets.US_ASCII));
MediaType contentType = new MediaType(MediaType.MULTIPART_FORM_DATA, parameters);
HttpHeaders headers = outputMessage.getHeaders();

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -199,7 +199,7 @@ public class WebSocketMessageBrokerStats { @@ -199,7 +199,7 @@ public class WebSocketMessageBrokerStats {
", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" +
", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" +
", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" +
", outboundChannel" + getClientOutboundExecutorStatsInfo() + "]" +
", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" +
", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]";
}

Loading…
Cancel
Save