Skip to content

Avoid duplicate registration of @ControllerAdvice implementing both RequestBodyAdvice and ResponseBodyAdvice #22638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

liquanchen9
Copy link
Contributor

fixbug: duplicate add on ControllerAdvice both RequestBodyAdvice and ResponseBodyAdvice

fixbug: duplicate add on ControllerAdvice both RequestBodyAdvice and ResponseBodyAdvice
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 22, 2019
@pivotal-issuemaster
Copy link

@liquanchen9 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug labels Mar 22, 2019
@pivotal-issuemaster
Copy link

@liquanchen9 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@sbrannen sbrannen removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 22, 2019
@sbrannen sbrannen self-assigned this Mar 22, 2019
@sbrannen
Copy link
Member

Good catch. I'm not sure how often people implement RequestBodyAdvice and ResponseBodyAdvice in the same class, but it's certainly possible.

If you could sign the CLA and submit a test that was failing before the change that would be greatly appreciated.

@sbrannen sbrannen added the status: waiting-for-feedback We need additional information before we can continue label Mar 22, 2019
@sbrannen sbrannen changed the title fixbug: duplicate add Avoid duplicate registration of @ControllerAdvice implementing both RequestBodyAdvice and ResponseBodyAdvice Mar 22, 2019
@sbrannen sbrannen added this to the 5.1.6 milestone Mar 22, 2019
@sbrannen
Copy link
Member

Since this is a trivial change, @liquanchen9, we have decided to forgo the requirement to sign the CLA.

Thanks for your contribution!

sbrannen added a commit that referenced this pull request Mar 26, 2019
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.0.x labels Mar 26, 2019
@sbrannen sbrannen removed the status: waiting-for-feedback We need additional information before we can continue label Mar 26, 2019
sbrannen added a commit that referenced this pull request Mar 26, 2019
Prior to this commit, if a @ControllerAdvice bean implemented both
RequestBodyAdvice and ResponseBodyAdvice, it was only supported as
RequestBodyAdvice, meaning it was never invoked as ResponseBodyAdvice.

This commit revises RequestResponseBodyAdviceChain to ensure that a
single bean implementing both types of body advice is in fact handled
as both types of advice.

See gh-22638
sbrannen added a commit that referenced this pull request Mar 26, 2019
Prior to this commit, if a @ControllerAdvice bean implemented both
RequestBodyAdvice and ResponseBodyAdvice, it was registered twice in
RequestMappingHandlerAdapter, leading to duplicate application of the
same logic.

This commit ensures that such instances are only registered once.

Fixes gh-22638
sbrannen added a commit that referenced this pull request Mar 26, 2019
@sbrannen sbrannen closed this in 93de5f4 Mar 26, 2019
sbrannen added a commit that referenced this pull request Mar 26, 2019
Prior to this commit, if a @ControllerAdvice bean implemented both
RequestBodyAdvice and ResponseBodyAdvice, it was only supported as
RequestBodyAdvice, meaning it was never invoked as ResponseBodyAdvice.

This commit revises RequestResponseBodyAdviceChain to ensure that a
single bean implementing both types of body advice is in fact handled
as both types of advice.

See gh-22638
sbrannen added a commit that referenced this pull request Mar 26, 2019
Prior to this commit, if a @ControllerAdvice bean implemented both
RequestBodyAdvice and ResponseBodyAdvice, it was registered twice in
RequestMappingHandlerAdapter, leading to duplicate application of the
same logic.

This commit ensures that such instances are only registered once.

Fixes gh-22638
sbrannen added a commit that referenced this pull request Mar 26, 2019
@pivotal-issuemaster
Copy link

@liquanchen9 Thank you for signing the Contributor License Agreement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants