diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 7e12f7d0b34..fede5f182e2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.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"); * you may not use this file except in compliance with the License. @@ -107,6 +107,7 @@ import org.springframework.web.util.WebUtils; * * @author Rossen Stoyanchev * @author Juergen Hoeller + * @author Sam Brannen * @since 3.1 * @see HandlerMethodArgumentResolver * @see HandlerMethodReturnValueHandler @@ -612,16 +613,18 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter logger.info("Detected @InitBinder methods in " + adviceBean); } } - if (RequestBodyAdvice.class.isAssignableFrom(beanType)) { - requestResponseBodyAdviceBeans.add(adviceBean); - if (logger.isInfoEnabled()) { - logger.info("Detected RequestBodyAdvice bean in " + adviceBean); - } - } - if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) { + + boolean isRequestBodyAdvice = RequestBodyAdvice.class.isAssignableFrom(beanType); + boolean isResponseBodyAdvice = ResponseBodyAdvice.class.isAssignableFrom(beanType); + if (isRequestBodyAdvice || isResponseBodyAdvice) { requestResponseBodyAdviceBeans.add(adviceBean); if (logger.isInfoEnabled()) { - logger.info("Detected ResponseBodyAdvice bean in " + adviceBean); + if (isRequestBodyAdvice) { + logger.info("Detected RequestBodyAdvice bean in " + adviceBean); + } + else { + logger.info("Detected ResponseBodyAdvice bean in " + adviceBean); + } } } }