Polishing

This commit is contained in:
Juergen Hoeller 2019-09-04 12:19:08 +02:00
parent 3bc27e8d14
commit 48934cba1b
5 changed files with 17 additions and 15 deletions

View File

@ -64,7 +64,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
@BeforeEach
void setUp() {
void setup() {
this.oldRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
this.newRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
@ -78,7 +78,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@AfterEach
void tearDown() throws Exception {
void reset() {
RequestContextHolder.setRequestAttributes(null);
}

View File

@ -58,7 +58,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
@BeforeEach
void setUp() {
void setup() {
MockHttpServletRequest oldRequestWithSession = new MockHttpServletRequest();
oldRequestWithSession.setSession(new MockHttpSession());
this.oldRequestAttributesWithSession = new ServletRequestAttributes(oldRequestWithSession);
@ -69,7 +69,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
}
@AfterEach
void tearDown() throws Exception {
void reset() {
RequestContextHolder.resetRequestAttributes();
}

View File

@ -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.
@ -705,8 +705,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
}
private GroovyDynamicElementReader createDynamicElementReader(String namespace) {
XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource(
"Groovy"));
XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(
new DescriptiveResource("Groovy"));
BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext);
boolean decorating = (this.currentBeanDefinition != null);
if (!decorating) {

View File

@ -36,7 +36,7 @@ public class LookupAnnotationTests {
@BeforeEach
public void setUp() {
public void setup() {
beanFactory = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor aabpp = new AutowiredAnnotationBeanPostProcessor();
aabpp.setBeanFactory(beanFactory);
@ -122,6 +122,7 @@ public class LookupAnnotationTests {
@Lookup
public abstract TestBean getTwoArguments(String name, int age);
// no @Lookup annotation
public abstract TestBean getThreeArguments(String name, int age, int anotherArg);
}

View File

@ -81,8 +81,7 @@ import org.springframework.web.server.ServerWebExchange;
* @author Rossen Stoyanchev
* @since 5.0
*/
public class ViewResolutionResultHandler extends HandlerResultHandlerSupport
implements HandlerResultHandler, Ordered {
public class ViewResolutionResultHandler extends HandlerResultHandlerSupport implements HandlerResultHandler, Ordered {
private static final Object NO_VALUE = new Object();
@ -145,6 +144,7 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport
return this.defaultViews;
}
@Override
public boolean supports(HandlerResult result) {
if (hasModelAnnotation(result.getReturnTypeSource())) {
@ -162,14 +162,10 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport
return (CharSequence.class.isAssignableFrom(type) || Rendering.class.isAssignableFrom(type) ||
Model.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type) ||
Void.class.equals(type) || void.class.equals(type) || View.class.isAssignableFrom(type) ||
void.class == type || Void.class == type || View.class.isAssignableFrom(type) ||
!BeanUtils.isSimpleProperty(type));
}
private boolean hasModelAnnotation(MethodParameter parameter) {
return parameter.hasMethodAnnotation(ModelAttribute.class);
}
@Override
@SuppressWarnings("unchecked")
public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result) {
@ -251,6 +247,11 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport
});
}
private boolean hasModelAnnotation(MethodParameter parameter) {
return parameter.hasMethodAnnotation(ModelAttribute.class);
}
/**
* Select a default view name when a controller did not specify it.
* Use the request path the leading and trailing slash stripped.