Browse Source

Merge branch '5.1.x'

pull/23006/head
Juergen Hoeller 7 years ago
parent
commit
171e8f56a3
  1. 5
      spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java
  2. 24
      spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java
  3. 10
      spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java
  4. 25
      spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java
  5. 2
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java

5
spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -206,7 +206,8 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
} }
else { else {
// We need to create a method invocation... // We need to create a method invocation...
MethodInvocation invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain); MethodInvocation invocation =
new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);
// Proceed to the joinpoint through the interceptor chain. // Proceed to the joinpoint through the interceptor chain.
retVal = invocation.proceed(); retVal = invocation.proceed();
} }

24
spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java

@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue;
public class ResourceEditorTests { public class ResourceEditorTests {
@Test @Test
public void sunnyDay() throws Exception { public void sunnyDay() {
PropertyEditor editor = new ResourceEditor(); PropertyEditor editor = new ResourceEditor();
editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class"); editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class");
Resource resource = (Resource) editor.getValue(); Resource resource = (Resource) editor.getValue();
@ -46,20 +46,20 @@ public class ResourceEditorTests {
} }
@Test @Test
public void ctorWithNullCtorArgs() throws Exception { public void ctorWithNullCtorArgs() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
new ResourceEditor(null, null)); new ResourceEditor(null, null));
} }
@Test @Test
public void setAndGetAsTextWithNull() throws Exception { public void setAndGetAsTextWithNull() {
PropertyEditor editor = new ResourceEditor(); PropertyEditor editor = new ResourceEditor();
editor.setAsText(null); editor.setAsText(null);
assertEquals("", editor.getAsText()); assertEquals("", editor.getAsText());
} }
@Test @Test
public void setAndGetAsTextWithWhitespaceResource() throws Exception { public void setAndGetAsTextWithWhitespaceResource() {
PropertyEditor editor = new ResourceEditor(); PropertyEditor editor = new ResourceEditor();
editor.setAsText(" "); editor.setAsText(" ");
assertEquals("", editor.getAsText()); assertEquals("", editor.getAsText());
@ -67,6 +67,20 @@ public class ResourceEditorTests {
@Test @Test
public void testSystemPropertyReplacement() { public void testSystemPropertyReplacement() {
PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}");
Resource resolved = (Resource) editor.getValue();
assertEquals("foo", resolved.getFilename());
}
finally {
System.getProperties().remove("test.prop");
}
}
@Test
public void testSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceEditor(); PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo"); System.setProperty("test.prop", "foo");
try { try {
@ -80,7 +94,7 @@ public class ResourceEditorTests {
} }
@Test @Test
public void testStrictSystemPropertyReplacement() { public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false); PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false);
System.setProperty("test.prop", "foo"); System.setProperty("test.prop", "foo");
try { try {

10
spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java

@ -35,7 +35,7 @@ import static org.junit.Assert.assertTrue;
public class ResourceArrayPropertyEditorTests { public class ResourceArrayPropertyEditorTests {
@Test @Test
public void testVanillaResource() throws Exception { public void testVanillaResource() {
PropertyEditor editor = new ResourceArrayPropertyEditor(); PropertyEditor editor = new ResourceArrayPropertyEditor();
editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class"); editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class");
Resource[] resources = (Resource[]) editor.getValue(); Resource[] resources = (Resource[]) editor.getValue();
@ -44,7 +44,7 @@ public class ResourceArrayPropertyEditorTests {
} }
@Test @Test
public void testPatternResource() throws Exception { public void testPatternResource() {
// N.B. this will sometimes fail if you use classpath: instead of classpath*:. // N.B. this will sometimes fail if you use classpath: instead of classpath*:.
// The result depends on the classpath - if test-classes are segregated from classes // The result depends on the classpath - if test-classes are segregated from classes
// and they come first on the classpath (like in Maven) then it breaks, if classes // and they come first on the classpath (like in Maven) then it breaks, if classes
@ -61,9 +61,9 @@ public class ResourceArrayPropertyEditorTests {
PropertyEditor editor = new ResourceArrayPropertyEditor(); PropertyEditor editor = new ResourceArrayPropertyEditor();
System.setProperty("test.prop", "foo"); System.setProperty("test.prop", "foo");
try { try {
editor.setAsText("${test.prop}-${bar}"); editor.setAsText("${test.prop}");
Resource[] resources = (Resource[]) editor.getValue(); Resource[] resources = (Resource[]) editor.getValue();
assertEquals("foo-${bar}", resources[0].getFilename()); assertEquals("foo", resources[0].getFilename());
} }
finally { finally {
System.getProperties().remove("test.prop"); System.getProperties().remove("test.prop");
@ -71,7 +71,7 @@ public class ResourceArrayPropertyEditorTests {
} }
@Test @Test
public void testStrictSystemPropertyReplacement() { public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceArrayPropertyEditor( PropertyEditor editor = new ResourceArrayPropertyEditor(
new PathMatchingResourcePatternResolver(), new StandardEnvironment(), new PathMatchingResourcePatternResolver(), new StandardEnvironment(),
false); false);

25
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -59,7 +59,7 @@ public class DeferredResult<T> {
@Nullable @Nullable
private final Long timeout; private final Long timeoutValue;
private final Supplier<?> timeoutResult; private final Supplier<?> timeoutResult;
@ -88,35 +88,36 @@ public class DeferredResult<T> {
* <p>By default not set in which case the default configured in the MVC * <p>By default not set in which case the default configured in the MVC
* Java Config or the MVC namespace is used, or if that's not set, then the * Java Config or the MVC namespace is used, or if that's not set, then the
* timeout depends on the default of the underlying server. * timeout depends on the default of the underlying server.
* @param timeout timeout value in milliseconds * @param timeoutValue timeout value in milliseconds
*/ */
public DeferredResult(Long timeout) { public DeferredResult(Long timeoutValue) {
this(timeout, () -> RESULT_NONE); this(timeoutValue, () -> RESULT_NONE);
} }
/** /**
* Create a DeferredResult with a timeout value and a default result to use * Create a DeferredResult with a timeout value and a default result to use
* in case of timeout. * in case of timeout.
* @param timeout timeout value in milliseconds (ignored if {@code null}) * @param timeoutValue timeout value in milliseconds (ignored if {@code null})
* @param timeoutResult the result to use * @param timeoutResult the result to use
*/ */
public DeferredResult(@Nullable Long timeout, final Object timeoutResult) { public DeferredResult(@Nullable Long timeoutValue, final Object timeoutResult) {
this.timeoutResult = () -> timeoutResult; this.timeoutResult = () -> timeoutResult;
this.timeout = timeout; this.timeoutValue = timeoutValue;
} }
/** /**
* Variant of {@link #DeferredResult(Long, Object)} that accepts a dynamic * Variant of {@link #DeferredResult(Long, Object)} that accepts a dynamic
* fallback value based on a {@link Supplier}. * fallback value based on a {@link Supplier}.
* @param timeout timeout value in milliseconds (ignored if {@code null}) * @param timeoutValue timeout value in milliseconds (ignored if {@code null})
* @param timeoutResult the result supplier to use * @param timeoutResult the result supplier to use
* @since 5.1.1 * @since 5.1.1
*/ */
public DeferredResult(@Nullable Long timeout, Supplier<?> timeoutResult) { public DeferredResult(@Nullable Long timeoutValue, Supplier<?> timeoutResult) {
this.timeoutResult = timeoutResult; this.timeoutResult = timeoutResult;
this.timeout = timeout; this.timeoutValue = timeoutValue;
} }
/** /**
* Return {@code true} if this DeferredResult is no longer usable either * Return {@code true} if this DeferredResult is no longer usable either
* because it was previously set or because the underlying request expired. * because it was previously set or because the underlying request expired.
@ -154,7 +155,7 @@ public class DeferredResult<T> {
*/ */
@Nullable @Nullable
final Long getTimeoutValue() { final Long getTimeoutValue() {
return this.timeout; return this.timeoutValue;
} }
/** /**

2
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

Loading…
Cancel
Save