You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Adrian Nistor (JIRA)" <ji...@apache.org> on 2013/06/19 17:43:22 UTC

[jira] [Created] (WW-4116) Wasted work in PackageBasedActionConfigBuilder.checkPackageLocators()

Adrian Nistor created WW-4116:
---------------------------------

             Summary: Wasted work in PackageBasedActionConfigBuilder.checkPackageLocators()
                 Key: WW-4116
                 URL: https://issues.apache.org/jira/browse/WW-4116
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - Convention
    Affects Versions: 2.3.14.3
         Environment: any
            Reporter: Adrian Nistor


The problem appears in version 2.3.14.3 and in revision 1493157.  I
attached a two-line patch (patch.diff) that fixes it.

In method "PackageBasedActionConfigBuilder.checkPackageLocators", the
loop over "packageLocators" should only be executed when
"classPackageName.length() > 0" is "true", because the loop's only
side effect (the "return true;" statement) cannot be executed when
"classPackageName.length() > 0" is "false".  Note that
"classPackageName" is not modified inside the loop.

In fact, the loop over "packageLocators" should be executed only when
the condition of the loop's "if":

{code:java|borderStyle=solid}
if (classPackageName.length() > 0
        && (packageLocatorsBasePackage == null || classPackageName
        .startsWith(packageLocatorsBasePackage)))
{code}

is "true", because the loop's only side effect (the "return true;"
statement) cannot be executed when this condition is false.  Also, the
elements inside this condition are not modified inside the loop.  I
attached a second patch (patchFull.diff) that implements this complete
solution.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira