[
https://issues.apache.org/jira/browse/WW-5821?focusedWorklogId=1056483&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056483
]
ASF GitHub Bot logged work on WW-5821:
--------------------------------------
Author: ASF GitHub Bot
Created on: 22/Nov/26 09:11
Start Date: 22/Nov/26 09:11
Worklog Time Spent: 10m
Work Description: sonarqubecloud[bot] commented on PR #2151:
URL: https://github.com/apache/struts/pull/2151#issuecomment-7076992420
## [](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2151)
**Quality Gate passed**
Issues
 [0 New
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2151&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2151&issueStatuses=ACCEPTED)
Measures
 [0 Security
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=2151&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2151&metric=new_coverage&view=list)
 [0.0% Duplication on New
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2151&metric=new_duplicated_lines_density&view=list)
<!
Issue Time Tracking
-------------------
Worklog Id: (was: 1056483)
Time Spent: 40m (was: 0.5h)
> HttpMethodInterceptor raises IllegalArgumentException for an unknown HTTP
> method on an HttpMethodAware action
> -------------------------------------------------------------------------------------------------------------
>
> Key: WW-5821
> URL: https://issues.apache.org/jira/browse/WW-5821
> Project: Struts 2
> Issue Type: Bug
> Components: Core Interceptors
> Reporter: Lukasz Lenart
> Priority: Major
> Fix For: 7.6.0
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> When an action implements {{HttpMethodAware}}, {{HttpMethodInterceptor}}
> converts the request method with {{HttpMethod.parse()}}, which calls
> {{valueOf()}} with no fallback. A request method outside the enum constants,
> such as {{PROPFIND}}, {{MKCOL}} or {{REPORT}}, raises
> {{IllegalArgumentException}} before the allowed-method checks run, so the
> client gets a 500 instead of the configured rejection.
> h2. Steps to reproduce
> # Define an action that implements {{HttpMethodAware}} and restricts methods,
> for example with {{@AllowedHttpMethod(POST)}} or {{http-method="POST"}}.
> # Send {{PROPFIND}} to that action.
> h2. Expected
> The request is rejected like any other disallowed method: the bad-request
> result, or {{405 Method Not Allowed}} with an {{Allow}} header when no such
> result is mapped.
> h2. Actual
> {code}java.lang.IllegalArgumentException: No enum constant
> org.apache.struts2.interceptor.httpmethod.HttpMethod.PROPFIND
> at java.base/java.lang.Enum.valueOf(Enum.java:273)
> at
> org.apache.struts2.interceptor.httpmethod.HttpMethod.parse(HttpMethod.java:40)
> {code}
> h2. Proposed change
> Add {{HttpMethod.parseOrNull()}}, a case-insensitive lookup that returns
> {{null}} for an unknown method. The interceptor passes that value to
> {{HttpMethodAware.setMethod()}}, documented as {{null}} for an unknown
> method, and falls through to the existing allowed-method check. {{parse()}}
> switches to {{Locale.ROOT}}, and {{XmlDocConfigurationProvider}} uses it for
> the {{http-method}} attribute.
> Pull request: [apache/struts#2043|https://github.com/apache/struts/pull/2043]
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)