Avoid duplicate registration of [RequestBody|ResponseBody]Advice @ControllerAdvice
Prior to this commit, if a @ControllerAdvice implemented both RequestBodyAdvice and ResponseBodyAdvice, it was registered twice in RequestMappingHandlerAdapter. This commit ensures that such instances are only registered once. Closes gh-22638
This commit is contained in:
@@ -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.
|
||||
@@ -598,10 +598,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
if (!binderMethods.isEmpty()) {
|
||||
this.initBinderAdviceCache.put(adviceBean, binderMethods);
|
||||
}
|
||||
if (RequestBodyAdvice.class.isAssignableFrom(beanType)) {
|
||||
requestResponseBodyAdviceBeans.add(adviceBean);
|
||||
}
|
||||
if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
|
||||
if (RequestBodyAdvice.class.isAssignableFrom(beanType) || ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
|
||||
requestResponseBodyAdviceBeans.add(adviceBean);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user