diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 682748d..f0ff46d 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -92,6 +92,9 @@ The type attribute can be add,update,fix,remove. Deprecate LogConfigurationException.cause in favor of getCause(). + + Fix SpotBugs [ERROR] High: Found reliance on default encoding in org.apache.commons.logging.LogFactory.initDiagnostics(): new java.io.PrintStream(OutputStream) [org.apache.commons.logging.LogFactory] At LogFactory.java:[line 1205] DM_DEFAULT_ENCODING. + Bump Java from 6 to 8. diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java index 88418d7..2bce859 100644 --- a/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/src/main/java/org/apache/commons/logging/LogFactory.java @@ -24,6 +24,8 @@ import java.io.PrintStream; import java.lang.ref.WeakReference; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Enumeration; @@ -1202,7 +1204,7 @@ public abstract class LogFactory { try { // open the file in append mode final FileOutputStream fos = new FileOutputStream(dest, true); - return new PrintStream(fos); + return new PrintStream(fos, false, StandardCharsets.UTF_8.name()); } catch (final IOException ex) { // We should report this to the user - but how? return null;