[
https://issues.apache.org/jira/browse/WW-5792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart updated WW-5792:
------------------------------
Description:
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.
was:
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 fails configuration loading with the "is not public"
{{ConfigurationException}}, the same way a missing no-arg constructor does. The
{{catch (RuntimeException)}} handler is there for container-specific failures
(e.g. request- or session-scoped Spring beans); it should not swallow the
provider's own validation errors — for example by rethrowing
{{ConfigurationException}} before the generic handler.
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.
> 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
>
>
> 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)