Skip to content

Commit ece2c90

Browse files
committed
RequestMappingHandlerAdapter allows for overriding handleInternal
Issue: SPR-12460
1 parent 282aded commit ece2c90

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java

+27-30
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
141141

142142
private Long asyncRequestTimeout;
143143

144-
private CallableProcessingInterceptor[] callableInterceptors = new CallableProcessingInterceptor[] {};
144+
private CallableProcessingInterceptor[] callableInterceptors = new CallableProcessingInterceptor[0];
145145

146-
private DeferredResultProcessingInterceptor[] deferredResultInterceptors = new DeferredResultProcessingInterceptor[] {};
146+
private DeferredResultProcessingInterceptor[] deferredResultInterceptors = new DeferredResultProcessingInterceptor[0];
147147

148148
private boolean ignoreDefaultModelOnRedirect = false;
149149

@@ -172,21 +172,18 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
172172
new LinkedHashMap<ControllerAdviceBean, Set<Method>>();
173173

174174

175-
/**
176-
* Default constructor.
177-
*/
178175
public RequestMappingHandlerAdapter() {
179-
180176
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
181-
stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316
177+
stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316
182178

183-
this.messageConverters = new ArrayList<HttpMessageConverter<?>>();
179+
this.messageConverters = new ArrayList<HttpMessageConverter<?>>(4);
184180
this.messageConverters.add(new ByteArrayHttpMessageConverter());
185181
this.messageConverters.add(stringHttpMessageConverter);
186182
this.messageConverters.add(new SourceHttpMessageConverter<Source>());
187183
this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
188184
}
189185

186+
190187
/**
191188
* Provide resolvers for custom argument types. Custom resolvers are ordered
192189
* after built-in ones. To override the built-in support for argument
@@ -330,7 +327,7 @@ public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters
330327
* Return the configured message body converters.
331328
*/
332329
public List<HttpMessageConverter<?>> getMessageConverters() {
333-
return messageConverters;
330+
return this.messageConverters;
334331
}
335332

336333
/**
@@ -355,10 +352,10 @@ public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer
355352
}
356353

357354
/**
358-
* Return the configured WebBindingInitializer, or {@code null}.
355+
* Return the configured WebBindingInitializer, or {@code null} if none.
359356
*/
360357
public WebBindingInitializer getWebBindingInitializer() {
361-
return webBindingInitializer;
358+
return this.webBindingInitializer;
362359
}
363360

364361
/**
@@ -477,9 +474,8 @@ public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDisc
477474
}
478475

479476
/**
480-
* {@inheritDoc}
481-
* <p>A {@link ConfigurableBeanFactory} is expected for resolving
482-
* expressions in method argument default values.
477+
* A {@link ConfigurableBeanFactory} is expected for resolving expressions
478+
* in method argument default values.
483479
*/
484480
@Override
485481
public void setBeanFactory(BeanFactory beanFactory) {
@@ -489,15 +485,15 @@ public void setBeanFactory(BeanFactory beanFactory) {
489485
}
490486

491487
/**
492-
* Return the owning factory of this bean instance, or {@code null}.
488+
* Return the owning factory of this bean instance, or {@code null} if none.
493489
*/
494490
protected ConfigurableBeanFactory getBeanFactory() {
495491
return this.beanFactory;
496492
}
497493

494+
498495
@Override
499496
public void afterPropertiesSet() {
500-
501497
// Do this first, it may add ResponseBody advice beans
502498
initControllerAdviceCache();
503499

@@ -670,6 +666,7 @@ private List<HandlerMethodReturnValueHandler> getDefaultReturnValueHandlers() {
670666
return handlers;
671667
}
672668

669+
673670
/**
674671
* Always return {@code true} since any method argument and return value
675672
* type will be processed in some way. A method argument not recognized
@@ -683,19 +680,8 @@ protected boolean supportsInternal(HandlerMethod handlerMethod) {
683680
return true;
684681
}
685682

686-
/**
687-
* This implementation always returns -1. An {@code @RequestMapping}
688-
* method can calculate the lastModified value, call
689-
* {@link WebRequest#checkNotModified(long)}, and return {@code null}
690-
* if the result of that call is {@code true}.
691-
*/
692-
@Override
693-
protected long getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod) {
694-
return -1;
695-
}
696-
697683
@Override
698-
protected final ModelAndView handleInternal(HttpServletRequest request,
684+
protected ModelAndView handleInternal(HttpServletRequest request,
699685
HttpServletResponse response, HandlerMethod handlerMethod) throws Exception {
700686

701687
if (getSessionAttributesHandler(handlerMethod).hasSessionAttributes()) {
@@ -722,8 +708,19 @@ protected final ModelAndView handleInternal(HttpServletRequest request,
722708
}
723709

724710
/**
725-
* Return the {@link SessionAttributesHandler} instance for the given
726-
* handler type, never {@code null}.
711+
* This implementation always returns -1. An {@code @RequestMapping} method can
712+
* calculate the lastModified value, call {@link WebRequest#checkNotModified(long)},
713+
* and return {@code null} if the result of that call is {@code true}.
714+
*/
715+
@Override
716+
protected long getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod) {
717+
return -1;
718+
}
719+
720+
721+
/**
722+
* Return the {@link SessionAttributesHandler} instance for the given handler type
723+
* (never {@code null}).
727724
*/
728725
private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handlerMethod) {
729726
Class<?> handlerType = handlerMethod.getBeanType();

0 commit comments

Comments
 (0)