[ 
https://issues.apache.org/jira/browse/WW-5792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lukasz Lenart resolved WW-5792.
-------------------------------
    Resolution: Fixed

> XmlDocConfigurationProvider#verifyAction does not fail startup for a 
> non-public action class
> --------------------------------------------------------------------------------------------
>
>                 Key: WW-5792
>                 URL: https://issues.apache.org/jira/browse/WW-5792
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.5.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> h2. Problem
> {{XmlDocConfigurationProvider#verifyAction}} is meant to fail fast when an 
> action class declared in XML is not public. It throws a 
> {{ConfigurationException}} with the message "Action class [...] is not 
> public" — but the throw happens inside the same {{try}} block whose {{catch 
> (RuntimeException ex)}} handler logs at INFO ("Unable to verify action class 
> [...] exists at initialization") and carries on. {{ConfigurationException}} 
> extends {{StrutsException}}, which extends {{RuntimeException}}, so the check 
> never takes effect and startup continues.
> The sibling check works: a class without a public no-arg constructor raises 
> {{NoSuchMethodException}}, which has its own handler that rethrows as 
> {{ConfigurationException}}.
> h2. Reproduction
> Calling {{verifyAction}} (with the default {{ObjectFactory}}, so 
> {{isNoArgConstructorRequired()}} is true) on:
> * a package-private action class → returns normally, nothing but an INFO log 
> line;
> * a public class without a public no-arg constructor → throws 
> {{ConfigurationException: Action class [...] does not have a public no-arg 
> constructor}}.
> Confirmed on {{main}} with a throwaway test in 
> {{org.apache.struts2.config.providers}} that injects a 
> {{StrutsXmlConfigurationProvider}} from the test container and calls 
> {{verifyAction}} directly for both classes.
> h2. Expected
> A non-public action class logs a WARN naming the class and its location, 
> saying it will fail startup in Struts 8.0.0. Configuration loading continues 
> as before. Failing startup is tracked in WW-5809 (8.0.0).
> h2. Notes
> Found while adding the same check to the Struts Boot registry provider 
> (WW-5791), which fails startup for non-public action classes. There is 
> currently no core test for the non-public branch.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to