提交 93de5f40 编写于 作者: 李全城 提交者: Sam Brannen

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
上级 f66362a0
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -598,10 +598,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter ...@@ -598,10 +598,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
if (!binderMethods.isEmpty()) { if (!binderMethods.isEmpty()) {
this.initBinderAdviceCache.put(adviceBean, binderMethods); this.initBinderAdviceCache.put(adviceBean, binderMethods);
} }
if (RequestBodyAdvice.class.isAssignableFrom(beanType)) { if (RequestBodyAdvice.class.isAssignableFrom(beanType) || ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
requestResponseBodyAdviceBeans.add(adviceBean);
}
if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
requestResponseBodyAdviceBeans.add(adviceBean); requestResponseBodyAdviceBeans.add(adviceBean);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册