Use StandardCharsets.UTF_8 94/31994/1
authorRobert Varga <robert.varga@pantheon.sk>
Sat, 2 Jan 2016 11:43:03 +0000 (12:43 +0100)
committerRobert Varga <robert.varga@pantheon.sk>
Sat, 2 Jan 2016 11:43:03 +0000 (12:43 +0100)
Do not look up the charset, but use a global shared instance.

Change-Id: I43ae1e93c0a13675585e69cf32bbf46d80c1ebfa
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
util/src/main/java/org/opendaylight/protocol/util/ByteArray.java

index b09856e3f45a130085e224159261ee16b1d1b9ad..93fbb278aeb117f178eac3fb1834a32dcd0ed57e 100644 (file)
@@ -14,7 +14,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.BitSet;
 import org.slf4j.Logger;
@@ -277,7 +277,7 @@ public final class ByteArray {
      */
     public static String bytesToHRString(final byte[] bytes) {
         try {
-            return Charset.forName("UTF-8").newDecoder().decode(ByteBuffer.wrap(bytes)).toString();
+            return StandardCharsets.UTF_8.newDecoder().decode(ByteBuffer.wrap(bytes)).toString();
         } catch (final CharacterCodingException e) {
             LOG.debug("Could not apply UTF-8 encoding.", e);
             return Arrays.toString(bytes);