peval / owasp-esapi-java

Automatically exported from code.google.com/p/owasp-esapi-java
Other
0 stars 0 forks source link

Logger.log is is slow #267

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. logger = Log4JLogger.getLogger(TestESAPIValidationPatterns.class);
2. logger.warn("starting up");
3. With a debugger, step through the "warn" method's implementation

        // log the message
        log(level, "[" + typeInfo + getUserInfo() + " -> " + appInfo + "] " + clean, throwable);

String concatenation in the above code creates a StringBuilder instance for 
each '+' operation.  Instead, the code should use StringBuilder directly. Such 
as:

        // log the message
                StringBuilder msg = new StringBuilder(60);
                msg.append('['; msg.append(typeInfo); msg.append.(" -> "); msg.append(appinfo);
                msg.apend(']'); msg.append(clean);
        log(level, msg.toString(), throwable);

What is the expected output? What do you see instead?

Performance is poor for this frequently invoked method.

What version of the product are you using? On what operating system?

2.0.1 on MacOS Lion

Does this issue affect only a specified browser or set of browsers?

No

Please provide any additional information below.

Original issue reported on code.google.com by bschoeni on 9 Apr 2012 at 7:33

GoogleCodeExporter commented 9 years ago
Java 1.5 appears to inline the StringBuilder, so this is not a problem and 
should be junked.  

Original comment by bschoeni on 9 Apr 2012 at 7:52