commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1536835 - in /commons/proper/lang/trunk: findbugs-exclude-filter.xml src/main/java/org/apache/commons/lang3/StringUtils.java
Date Tue, 29 Oct 2013 18:16:31 GMT
Author: britter
Date: Tue Oct 29 18:16:29 2013
New Revision: 1536835

URL: http://svn.apache.org/r1536835
Log:
Make usage of default charset explicit and remove FindBugs exclusion. Kudos to Sebb for spotting
this.

Modified:
    commons/proper/lang/trunk/findbugs-exclude-filter.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java

Modified: commons/proper/lang/trunk/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/findbugs-exclude-filter.xml?rev=1536835&r1=1536834&r2=1536835&view=diff
==============================================================================
--- commons/proper/lang/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/lang/trunk/findbugs-exclude-filter.xml Tue Oct 29 18:16:29 2013
@@ -48,16 +48,6 @@
     <Bug pattern="NP_BOOLEAN_RETURN_NULL" />
   </Match>
 
-  <!-- Reason: methods are supposed to fall back to default encoding if no charset is
specified -->
-  <Match>
-    <Class name="org.apache.commons.lang3.StringUtils" />
-    <Or>
-      <Method name="toString" />
-      <Method name="toEncodedString" />
-    </Or>
-    <Bug pattern="DM_DEFAULT_ENCODING" />
-  </Match>
-
   <!-- Reason: base class cannot be changed and field is properly checked against null
so behavior is OK -->
   <Match>
     <Class name="org.apache.commons.lang3.text.ExtendedMessageFormat" />

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1536835&r1=1536834&r2=1536835&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java Tue
Oct 29 18:16:29 2013
@@ -7449,7 +7449,7 @@ public class StringUtils {
      * @since 3.1
      */
     public static String toString(final byte[] bytes, final String charsetName) throws UnsupportedEncodingException
{
-        return charsetName == null ? new String(bytes) : new String(bytes, charsetName);
+        return charsetName != null ? new String(bytes, charsetName) : new String(bytes, Charset.defaultCharset());
     }
 
     /**
@@ -7467,7 +7467,7 @@ public class StringUtils {
      * @since 3.2
      */
     public static String toEncodedString(byte[] bytes, Charset charset) throws UnsupportedEncodingException
{
-        return charset == null ? new String(bytes) : new String(bytes, charset);
+        return new String(bytes, charset != null ? charset : Charset.defaultCharset());
     }
 
 }



Mime
View raw message