Skip to content

Conversation

YongGoose
Copy link

fixes #30938

Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

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.

@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Oct 1, 2025
Copy link
Member

@sbrannen sbrannen left a comment

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.

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

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-issues spring-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 <[email protected]>
Signed-off-by: yongjunhong <[email protected]>
Signed-off-by: yongjunhong <[email protected]>
@YongGoose
Copy link
Author

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
Author

@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!!

Copy link
Member

@sbrannen sbrannen left a comment

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.

Comment on lines 218 to 219
String methodPackageName = (methodPackage != null) ? methodPackage.getName() : "default package";
String handlerPackageName = (handlerPackage != null) ? handlerPackage.getName() : "default package";
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe java.lang.Package.getName() can return null on Java 17.

Comment on lines 221 to 226
throw new IllegalStateException(
"Package-private method [" + method + "] on CGLIB proxy class [" + declaringClass.getName() +
"] from package [" + methodPackageName + "] cannot be advised when used by handler class [" +
handlerType.getName() + "] from package [" + handlerPackageName + "] because it is effectively private. " +
"Either make the method public/protected or use interface-based JDK proxying instead.");
}
Copy link
Member

@sbrannen sbrannen Oct 10, 2025

Choose a reason for hiding this comment

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

Please introduce a test for this.

Copy link
Author

Choose a reason for hiding this comment

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

Done in dba200f !

Comment on lines 182 to 183


Copy link
Member

Choose a reason for hiding this comment

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

Please revert all unnecessary changes to this file.

protected @Nullable RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
int modifiers = method.getModifiers();

if (isCglibProxy(handlerType)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better if we extract this new CGLIB-proxy validation to a separate helper method in order not to clutter getMappingForMethod().

@sbrannen sbrannen self-assigned this Oct 10, 2025
@sbrannen sbrannen 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
YongGoose and others added 8 commits October 11, 2025 09:55
…c/method/annotation/RequestMappingHandlerMapping.java

Co-authored-by: Sam Brannen <[email protected]>
Signed-off-by: Yongjun Hong <[email protected]>
…c/method/annotation/RequestMappingHandlerMappingTests.java

Co-authored-by: Sam Brannen <[email protected]>
Signed-off-by: Yongjun Hong <[email protected]>
…c/method/annotation/RequestMappingHandlerMappingTests.java

Co-authored-by: Sam Brannen <[email protected]>
Signed-off-by: Yongjun Hong <[email protected]>
…c/method/annotation/RequestMappingHandlerMappingTests.java

Co-authored-by: Sam Brannen <[email protected]>
Signed-off-by: Yongjun Hong <[email protected]>
…c/method/annotation/RequestMappingHandlerMappingTests.java

Co-authored-by: Sam Brannen <[email protected]>
Signed-off-by: Yongjun Hong <[email protected]>
…c/method/annotation/RequestMappingHandlerMappingTests.java

Co-authored-by: Sam Brannen <[email protected]>
Signed-off-by: Yongjun Hong <[email protected]>
Signed-off-by: yongjunhong <[email protected]>
Signed-off-by: yongjunhong <[email protected]>
@YongGoose YongGoose requested a review from sbrannen October 11, 2025 12:52
Signed-off-by: yongjunhong <[email protected]>
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: 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 type: enhancement A 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