Skip to content

Reject effectively private handler methods on CGLIB proxied controllers - #35352

Closed
YongGoose wants to merge 15 commits into
spring-projects:mainfrom
YongGoose:feature/30938
Closed

Reject effectively private handler methods on CGLIB proxied controllers#35352
YongGoose wants to merge 15 commits into
spring-projects:mainfrom
YongGoose:feature/30938

Conversation

@YongGoose

Copy link
Copy Markdown
Contributor

fixes#30938

Signed-off-by: yongjunhong <yongjunh@apache.org>
rstoyanchev
rstoyanchev previously requested changes Oct 1, 2025

@rstoyanchevrstoyanchev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be checked in RequestMappingHandlerMapping when request mappings are being initialized?

It would avoid repeating that on every call.

@rstoyanchevrstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Oct 1, 2025

@sbrannensbrannen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I requested a few changes.

Please also take Rossen's comment into account.

@sbrannensbrannen added the status: waiting-for-feedback We need additional information before we can continue label Oct 3, 2025
@YongGoose

Copy link
Copy Markdown
ContributorAuthor

I'm currently traveling, so I should be able to work on it around Wednesday or Thursday this week.
@rstoyanchev@sbrannen Thank you both so much for the great reviews! 🙇🏻‍♂️

@spring-projects-issuesspring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 6, 2025
Signed-off-by: yongjunhong <yongjunh@apache.org>
Signed-off-by: yongjunhong <yongjunh@apache.org>
Signed-off-by: yongjunhong <yongjunh@apache.org>
@YongGoose

Copy link
Copy Markdown
ContributorAuthor

Couldn't this be checked in RequestMappingHandlerMapping when request mappings are being initialized?

It would avoid repeating that on every call.

Please take a look :)

@YongGoose

Copy link
Copy Markdown
ContributorAuthor

@sbrannen@rstoyanchev

If you have some time, I’d really appreciate it if you could take a look at this PR as well. 🙇🏻‍♂️🙇🏻‍♂️

It’s similar to the this PR, focusing on the access modifiers and proxies!!

@sbrannensbrannen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the requested changes. It's looking better. 👍

I've requested a few additional changes in this follow up review.

Also, please make analogous changes to org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping and org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMappingTests.

@sbrannensbrannen self-assigned this Oct 10, 2025
@sbrannensbrannen added type: enhancement A general enhancement status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Oct 10, 2025
YongGooseand others added 8 commits October 11, 2025 09:55
…c/method/annotation/RequestMappingHandlerMapping.java
Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Signed-off-by: Yongjun Hong <kevin0928@naver.com>
…c/method/annotation/RequestMappingHandlerMappingTests.java
Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Signed-off-by: Yongjun Hong <kevin0928@naver.com>
…c/method/annotation/RequestMappingHandlerMappingTests.java
Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Signed-off-by: Yongjun Hong <kevin0928@naver.com>
…c/method/annotation/RequestMappingHandlerMappingTests.java
Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Signed-off-by: Yongjun Hong <kevin0928@naver.com>
…c/method/annotation/RequestMappingHandlerMappingTests.java
Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Signed-off-by: Yongjun Hong <kevin0928@naver.com>
…c/method/annotation/RequestMappingHandlerMappingTests.java
Co-authored-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Signed-off-by: Yongjun Hong <kevin0928@naver.com>
Signed-off-by: yongjunhong <yongjunh@apache.org>
Signed-off-by: yongjunhong <yongjunh@apache.org>
…related tests
Signed-off-by: yongjunhong <yongjunh@apache.org>
Signed-off-by: yongjunhong <yongjunh@apache.org>
Signed-off-by: yongjunhong <yongjunh@apache.org>
@sbrannensbrannen removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 11, 2025
@sbrannensbrannen added this to the 7.0.0-RC1 milestone Oct 11, 2025
@sbrannensbrannen changed the title Prevent reflective invocation of private methods in web dispatcherReject invocation of private handler methods on CGLIB proxied controllerOct 11, 2025

@sbrannensbrannen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making all of the requested changes. 👍

I think this PR looks pretty good now, and I'll review it once more in detail before merging it into main.

@sbrannen
sbrannen dismissed rstoyanchev’s stale reviewOctober 11, 2025 15:21

The requested change has already been made.

@sbrannensbrannen changed the title Reject invocation of private handler methods on CGLIB proxied controllerReject invocation of effectively private handler methods on CGLIB proxied controllerOct 11, 2025
@sbrannensbrannen changed the title Reject invocation of effectively private handler methods on CGLIB proxied controllerReject effectively private handler methods on CGLIB proxied controllersOct 11, 2025
sbrannen added a commit that referenced this pull request Oct 11, 2025
@sbrannen

Copy link
Copy Markdown
Member

This has been merged into main in 8edc7cd and revised in 0389684.

Thanks! 👍

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoking private method on a CGLIB proxy should trigger a dedicated exception

4 participants

@YongGoose@sbrannen@rstoyanchev@spring-projects-issues