Skip to content

WW-5535 fix(core): enforce class-level HTTP method annotations for wildcard-resolved unannotated methods#1693

Open
lukaszlenart wants to merge 1 commit into
support/struts-6-x-xfrom
WW-5535-class-annotation-fallback-6x
Open

WW-5535 fix(core): enforce class-level HTTP method annotations for wildcard-resolved unannotated methods#1693
lukaszlenart wants to merge 1 commit into
support/struts-6-x-xfrom
WW-5535-class-annotation-fallback-6x

Conversation

@lukaszlenart
Copy link
Copy Markdown
Member

@lukaszlenart lukaszlenart commented May 20, 2026

Backports #1690 to the 6.x line.

The WW-5535 change in #1593 made wildcard-resolved methods report isMethodSpecified()=true, which left HttpMethodInterceptor's class-level annotation branch unreachable when the resolved method had no method-level annotation. Convert else if to a standalone if so the class-level check runs as a fallback; method-level annotations still take precedence.

See #1690 for the full analysis and affected scenario.

Adds three tests covering the unannotated-method fallback (mock proxy) and the end-to-end wildcard path through a real DefaultActionProxy.

Fixes WW-5535.

…ldcard-resolved unannotated methods

The WW-5535 change to DefaultActionProxy.resolveMethod() (which made
wildcard-resolved methods report isMethodSpecified()=true) interacted
with HttpMethodInterceptor's if/else-if so that the class-level
annotation branch became unreachable when the resolved method carried
no method-level annotation:

    if (isMethodSpecified()) {
        if (method has annotation) return doIntercept(method);
        // unannotated method falls through silently
    } else if (class has annotation) {
        return doIntercept(class);  // never reached when methodSpecified=true
    }

Convert the else-if to a standalone if so the class-level check is
always evaluated as a fallback. Method-level annotations still take
precedence — they are checked first and return early.

Adds three tests:
- testWildcardResolvedUnannotatedMethodRespectsClassLevelAnnotation:
  GET on a wildcard-resolved unannotated method is rejected when the
  class is @AllowedHttpMethod(POST).
- testWildcardResolvedUnannotatedMethodAllowsPostWithClassLevelAnnotation:
  POST on the same configuration succeeds.
- testWildcardResolvedExecuteRejectsGetThroughRealProxy: end-to-end
  via a real DefaultActionProxy with <action name="Wild-*" method="{1}">,
  resolving to ActionSupport.execute().
@sonarqubecloud
Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant