1
0

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.
This commit is contained in:
Gary Gregory
2023-11-25 11:55:22 -05:00
parent b9785548d6
commit 0f25dd6c0e
2 changed files with 6 additions and 1 deletions

View File

@@ -92,6 +92,9 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory"> <action type="fix" dev="ggregory" due-to="Gary Gregory">
Deprecate LogConfigurationException.cause in favor of getCause(). Deprecate LogConfigurationException.cause in favor of getCause().
</action> </action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">
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.
</action>
<!-- UPDATE --> <!-- UPDATE -->
<action dev="ggregory" type="update" due-to="Gary Gregory"> <action dev="ggregory" type="update" due-to="Gary Gregory">
Bump Java from 6 to 8. Bump Java from 6 to 8.

View File

@@ -24,6 +24,8 @@ import java.io.PrintStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.Enumeration; import java.util.Enumeration;
@@ -1202,7 +1204,7 @@ public abstract class LogFactory {
try { try {
// open the file in append mode // open the file in append mode
final FileOutputStream fos = new FileOutputStream(dest, true); final FileOutputStream fos = new FileOutputStream(dest, true);
return new PrintStream(fos); return new PrintStream(fos, false, StandardCharsets.UTF_8.name());
} catch (final IOException ex) { } catch (final IOException ex) {
// We should report this to the user - but how? // We should report this to the user - but how?
return null; return null;