struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "zhouyanming (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-4575) Fix performance regression
Date Mon, 07 Dec 2015 02:55:11 GMT

    [ https://issues.apache.org/jira/browse/WW-4575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15044239#comment-15044239
] 

zhouyanming edited comment on WW-4575 at 12/7/15 2:55 AM:
----------------------------------------------------------

SecurityMemberAccess.isPackageExcluded() is called heavily, replace regex with String.startsWith()
 will save lots of CPU time.
{code:java}
    protected boolean isPackageExcluded(Package targetPackage, Package memberPackage) {
        if (LOG.isWarnEnabled() && (targetPackage == null || memberPackage == null))
{
            LOG.warn("The use of the default (unnamed) package is discouraged!");
        }
        
        final String targetPackageName = targetPackage == null ? "" : targetPackage.getName();
        final String memberPackageName = memberPackage == null ? "" : memberPackage.getName();
        return isPackageExcluded(targetPackageName) || isPackageExcluded(memberPackageName);
    }
    
    protected static boolean isPackageExcluded(String packageName) {
		return packageName.equals("java.lang") || packageName.startsWith("java.lang.") || packageName.equals("ognl")
				|| packageName.startsWith("ognl.") || packageName.startsWith("javax.")
						&& !(packageName.equals("javax.servlet") || packageName.startsWith("javax.servlet."));
    }
{code}


was (Author: quaff):
SecurityMemberAccess.isPackageExcluded() is called heavily, replace regex with String.startsWith()
 will save lots of CPU time.
{code:java}
    protected boolean isPackageExcluded(Package targetPackage, Package memberPackage) {
        if (LOG.isWarnEnabled() && (targetPackage == null || memberPackage == null))
{
            LOG.warn("The use of the default (unnamed) package is discouraged!");
        }
        
        final String targetPackageName = targetPackage == null ? "" : targetPackage.getName();
        final String memberPackageName = memberPackage == null ? "" : memberPackage.getName();
        return isPackageExcluded(targetPackageName) || isPackageExcluded(memberPackageName);
    }
    
    protected boolean isPackageExcluded(String packageName) {
    	return packageName.startsWith("java.lang.") || packageName.startsWith("ognl.") 
    			|| packageName.startsWith("javax.") && !packageName.startsWith("javax.servlet.");
    }
{code}

> Fix performance regression
> --------------------------
>
>                 Key: WW-4575
>                 URL: https://issues.apache.org/jira/browse/WW-4575
>             Project: Struts 2
>          Issue Type: Task
>    Affects Versions: 2.3.20, 2.3.24
>            Reporter: zhouyanming
>             Fix For: 2.3.25
>
>
> I have an application run with struts2, recently I found my application performance downgraded
if struts2 upgraded. a special use case:
> ab -n 3000 -c 150 http://localhost/login
> ||requests/second||struts2 version||
> |684|2.3.16|
> |515|2.3.18|
> |312|2.3.24|
> It's appreciatory if someon test with official example.
> I think struts2 should focus on performance improvement, make struts2 more configurable
to deal with performance and security trade-off.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message