Use StringBuilder instead of StringBuffer for internal processing
This commit is contained in:
@@ -808,7 +808,7 @@ public class LogFactoryImpl extends LogFactory {
|
||||
logCategory,
|
||||
true);
|
||||
if (result == null) {
|
||||
final StringBuffer messageBuffer = new StringBuffer("User-specified log class '");
|
||||
final StringBuilder messageBuffer = new StringBuilder("User-specified log class '");
|
||||
messageBuffer.append(specifiedLogClassName);
|
||||
messageBuffer.append("' cannot be found or is not useable.");
|
||||
|
||||
@@ -876,7 +876,7 @@ public class LogFactoryImpl extends LogFactory {
|
||||
* @param name the (trimmed) name to be test against the candidate, not null
|
||||
* @param candidate the candidate name (not null)
|
||||
*/
|
||||
private void informUponSimilarName(final StringBuffer messageBuffer, final String name,
|
||||
private void informUponSimilarName(final StringBuilder messageBuffer, final String name,
|
||||
final String candidate) {
|
||||
if (name.equals(candidate)) {
|
||||
// Don't suggest a name that is exactly the same as the one the
|
||||
|
||||
@@ -19,7 +19,9 @@ package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
@@ -277,7 +279,7 @@ public class SimpleLog implements Log, Serializable {
|
||||
*/
|
||||
protected void log(final int type, final Object message, final Throwable t) {
|
||||
// Use a string buffer for better performance
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
||||
// Append date-time if so configured
|
||||
if(showDateTime) {
|
||||
@@ -321,8 +323,8 @@ public class SimpleLog implements Log, Serializable {
|
||||
buf.append(t.toString());
|
||||
buf.append(">");
|
||||
|
||||
final java.io.StringWriter sw = new java.io.StringWriter(1024);
|
||||
final java.io.PrintWriter pw = new java.io.PrintWriter(sw);
|
||||
final StringWriter sw = new StringWriter(1024);
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
pw.close();
|
||||
buf.append(sw.toString());
|
||||
@@ -344,6 +346,18 @@ public class SimpleLog implements Log, Serializable {
|
||||
System.err.println(buffer.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the content of the message accumulated in the specified
|
||||
* {@code StringBuffer} to the appropriate output destination. The
|
||||
* default implementation writes to {@code System.err}.
|
||||
*
|
||||
* @param buffer A {@code StringBuffer} containing the accumulated
|
||||
* text to be logged
|
||||
*/
|
||||
private void write(final Object buffer) {
|
||||
System.err.println(buffer.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given log level currently enabled?
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user