Polishing
This commit is contained in:
@@ -1291,8 +1291,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
mbd.setScope(containingBd.getScope());
|
||||
}
|
||||
|
||||
// Only cache the merged bean definition if we're already about to create an
|
||||
// instance of the bean, or at least have already created an instance before.
|
||||
// Cache the merged bean definition for the time being
|
||||
// (it might still get re-merged later on in order to pick up metadata changes)
|
||||
if (containingBd == null && isCacheBeanMetadata()) {
|
||||
this.mergedBeanDefinitions.put(beanName, mbd);
|
||||
}
|
||||
|
||||
@@ -1310,9 +1310,10 @@ public abstract class AnnotationUtils {
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
rethrowAnnotationConfigurationException(ex.getTargetException());
|
||||
throw new IllegalStateException("Could not obtain annotation attribute value of " + attributeName, ex);
|
||||
throw new IllegalStateException(
|
||||
"Could not obtain value for annotation attribute '" + attributeName + "' on " + annotation, ex);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1368,7 +1369,7 @@ public abstract class AnnotationUtils {
|
||||
try {
|
||||
return annotationType.getDeclaredMethod(attributeName).getDefaultValue();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -81,7 +81,9 @@ public class ResourceEditor extends PropertyEditorSupport {
|
||||
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
|
||||
* if no corresponding property could be found in the given {@code propertyResolver}
|
||||
*/
|
||||
public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) {
|
||||
public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver,
|
||||
boolean ignoreUnresolvablePlaceholders) {
|
||||
|
||||
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.propertyResolver = propertyResolver;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class AnnotationUtilsTests {
|
||||
assertNotNull(findAnnotation(m, Order.class));
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception {
|
||||
Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot");
|
||||
@@ -103,7 +103,7 @@ public class AnnotationUtilsTests {
|
||||
assertNotNull(findAnnotation(m, Order.class));
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
|
||||
Method m = Leaf.class.getMethod("metaAnnotatedOnLeaf");
|
||||
@@ -112,7 +112,7 @@ public class AnnotationUtilsTests {
|
||||
assertNotNull(findAnnotation(m, Order.class));
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception {
|
||||
Method m = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf");
|
||||
@@ -129,7 +129,7 @@ public class AnnotationUtilsTests {
|
||||
assertNotNull(findAnnotation(m, Order.class));
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception {
|
||||
Method m = Leaf.class.getMethod("metaAnnotatedOnRoot");
|
||||
@@ -259,42 +259,42 @@ public class AnnotationUtilsTests {
|
||||
assertNull("Should not find @Component on MetaCycleAnnotatedClass", component);
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findClassAnnotationOnInheritedAnnotationInterface() {
|
||||
Transactional tx = findAnnotation(InheritedAnnotationInterface.class, Transactional.class);
|
||||
assertNotNull("Should find @Transactional on InheritedAnnotationInterface", tx);
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findClassAnnotationOnSubInheritedAnnotationInterface() {
|
||||
Transactional tx = findAnnotation(SubInheritedAnnotationInterface.class, Transactional.class);
|
||||
assertNotNull("Should find @Transactional on SubInheritedAnnotationInterface", tx);
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findClassAnnotationOnSubSubInheritedAnnotationInterface() {
|
||||
Transactional tx = findAnnotation(SubSubInheritedAnnotationInterface.class, Transactional.class);
|
||||
assertNotNull("Should find @Transactional on SubSubInheritedAnnotationInterface", tx);
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findClassAnnotationOnNonInheritedAnnotationInterface() {
|
||||
Order order = findAnnotation(NonInheritedAnnotationInterface.class, Order.class);
|
||||
assertNotNull("Should find @Order on NonInheritedAnnotationInterface", order);
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findClassAnnotationOnSubNonInheritedAnnotationInterface() {
|
||||
Order order = findAnnotation(SubNonInheritedAnnotationInterface.class, Order.class);
|
||||
assertNotNull("Should find @Order on SubNonInheritedAnnotationInterface", order);
|
||||
}
|
||||
|
||||
/** @since 4.2 */
|
||||
// @since 4.2
|
||||
@Test
|
||||
public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
|
||||
Order order = findAnnotation(SubSubNonInheritedAnnotationInterface.class, Order.class);
|
||||
@@ -1241,12 +1241,9 @@ public class AnnotationUtilsTests {
|
||||
assertEquals("location: ", "", contextConfig.location());
|
||||
}
|
||||
|
||||
@ContextConfig(value="foo", location="bar")
|
||||
@Test(expected=AnnotationConfigurationException.class)
|
||||
@Test(expected = AnnotationConfigurationException.class)
|
||||
public void synthesizeAnnotationWithAttributeAliasesDifferentValues() throws Exception {
|
||||
Method m = AnnotationUtilsTests.class.getDeclaredMethod("synthesizeAnnotationWithAttributeAliasesDifferentValues");
|
||||
Annotation a = synthesizeAnnotation(m.getDeclaredAnnotation(ContextConfig.class));
|
||||
getValue(a);
|
||||
getValue(synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1823,13 +1820,13 @@ public class AnnotationUtilsTests {
|
||||
interface InterfaceWithRepeated {
|
||||
|
||||
@MyRepeatable("A")
|
||||
@MyRepeatableContainer({ @MyRepeatable("B"), @MyRepeatable("C") })
|
||||
@MyRepeatableContainer({@MyRepeatable("B"), @MyRepeatable("C")})
|
||||
@MyRepeatableMeta1
|
||||
void foo();
|
||||
}
|
||||
|
||||
@MyRepeatable("A")
|
||||
@MyRepeatableContainer({ @MyRepeatable("B"), @MyRepeatable("C") })
|
||||
@MyRepeatableContainer({@MyRepeatable("B"), @MyRepeatable("C")})
|
||||
@MyRepeatableMeta1
|
||||
static class MyRepeatableClass {
|
||||
}
|
||||
@@ -1838,7 +1835,7 @@ public class AnnotationUtilsTests {
|
||||
}
|
||||
|
||||
@MyRepeatable("X")
|
||||
@MyRepeatableContainer({ @MyRepeatable("Y"), @MyRepeatable("Z") })
|
||||
@MyRepeatableContainer({@MyRepeatable("Y"), @MyRepeatable("Z")})
|
||||
@MyRepeatableMeta2
|
||||
static class SubMyRepeatableWithAdditionalLocalDeclarationsClass extends MyRepeatableClass {
|
||||
}
|
||||
@@ -1968,7 +1965,7 @@ public class AnnotationUtilsTests {
|
||||
BrokenContextConfig[] value();
|
||||
}
|
||||
|
||||
@Hierarchy({ @ContextConfig("A"), @ContextConfig(location = "B") })
|
||||
@Hierarchy({@ContextConfig("A"), @ContextConfig(location = "B")})
|
||||
static class ConfigHierarchyTestCase {
|
||||
}
|
||||
|
||||
@@ -2320,7 +2317,7 @@ public class AnnotationUtilsTests {
|
||||
Filter[] excludeFilters() default {};
|
||||
}
|
||||
|
||||
@ComponentScan(excludeFilters = { @Filter(pattern = "*Foo"), @Filter(pattern = "*Bar") })
|
||||
@ComponentScan(excludeFilters = {@Filter(pattern = "*Foo"), @Filter(pattern = "*Bar")})
|
||||
static class ComponentScanClass {
|
||||
}
|
||||
|
||||
@@ -2348,4 +2345,8 @@ public class AnnotationUtilsTests {
|
||||
String text();
|
||||
}
|
||||
|
||||
@ContextConfig(value = "foo", location = "bar")
|
||||
interface ContextConfigMismatch {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
@WebServlet(asyncSupported = true)
|
||||
public class JettyHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
|
||||
|
||||
public JettyHttpHandlerAdapter(HttpHandler httpHandler) {
|
||||
super(httpHandler);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
|
||||
/**
|
||||
* {@link ServletHttpHandlerAdapter} extension that uses Jetty APIs for reading
|
||||
* {@link ServletHttpHandlerAdapter} extension that uses Tomcat APIs for reading
|
||||
* from the request and writing to the response with {@link ByteBuffer}.
|
||||
*
|
||||
* @author Violeta Georgieva
|
||||
@@ -39,7 +39,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
@WebServlet(asyncSupported = true)
|
||||
public class TomcatHttpHandlerAdapter extends ServletHttpHandlerAdapter {
|
||||
|
||||
|
||||
public TomcatHttpHandlerAdapter(HttpHandler httpHandler) {
|
||||
super(httpHandler);
|
||||
}
|
||||
|
||||
@@ -35,16 +35,15 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Integration tests with server-side {@link WebSocketHandler}s.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<?> getWebConfigClass() {
|
||||
return WebConfig.class;
|
||||
@@ -136,6 +135,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class EchoWebSocketHandler implements WebSocketHandler {
|
||||
|
||||
@Override
|
||||
@@ -145,6 +145,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class SubProtocolWebSocketHandler implements WebSocketHandler {
|
||||
|
||||
@Override
|
||||
@@ -160,6 +161,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CustomHeaderHandler implements WebSocketHandler {
|
||||
|
||||
@Override
|
||||
@@ -171,6 +173,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: workaround for suspected RxNetty WebSocket client issue
|
||||
// https://github.com/ReactiveX/RxNetty/issues/560
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -42,7 +42,8 @@ public interface ResponseBodyAdvice<T> {
|
||||
* and the selected {@code HttpMessageConverter} type.
|
||||
* @param returnType the return type
|
||||
* @param converterType the selected converter type
|
||||
* @return {@code true} if {@link #beforeBodyWrite} should be invoked, {@code false} otherwise
|
||||
* @return {@code true} if {@link #beforeBodyWrite} should be invoked;
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType);
|
||||
|
||||
@@ -55,7 +56,7 @@ public interface ResponseBodyAdvice<T> {
|
||||
* @param selectedConverterType the converter type selected to write to the response
|
||||
* @param request the current request
|
||||
* @param response the current response
|
||||
* @return the body that was passed in or a modified, possibly new instance
|
||||
* @return the body that was passed in or a modified (possibly new) instance
|
||||
*/
|
||||
T beforeBodyWrite(T body, MethodParameter returnType, MediaType selectedContentType,
|
||||
Class<? extends HttpMessageConverter<?>> selectedConverterType,
|
||||
|
||||
Reference in New Issue
Block a user