Skip to content

Commit 85202a5

Browse files
author
Andrew Or
committed
Use guava Charsets
1 parent 057135b commit 85202a5

File tree

1 file changed

+3
-3
lines changed
  • network/common/src/main/java/org/apache/spark/network/util

1 file changed

+3
-3
lines changed

network/common/src/main/java/org/apache/spark/network/util/JavaUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
import java.io.ObjectOutputStream;
2929

3030
import com.google.common.io.Closeables;
31+
import com.google.common.base.Charsets;
3132
import org.slf4j.Logger;
3233
import org.slf4j.LoggerFactory;
3334

3435
public class JavaUtils {
3536
private static final Logger logger = LoggerFactory.getLogger(JavaUtils.class);
36-
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
3737

3838
/** Closes the given object, ignoring IOExceptions. */
3939
public static void closeQuietly(Closeable closeable) {
@@ -83,14 +83,14 @@ public static int nonNegativeHash(Object obj) {
8383
* converted back to the same string through {@link #bytesToString(ByteBuffer)}.
8484
*/
8585
public static ByteBuffer stringToBytes(String s) {
86-
return ByteBuffer.wrap(s.getBytes(UTF8_CHARSET));
86+
return ByteBuffer.wrap(s.getBytes(Charsets.UTF_8));
8787
}
8888

8989
/**
9090
* Convert the given byte buffer to a string. The resulting string can be
9191
* converted back to the same byte buffer through {@link #stringToBytes(String)}.
9292
*/
9393
public static String bytesToString(ByteBuffer b) {
94-
return new String(b.array(), UTF8_CHARSET);
94+
return new String(b.array(), Charsets.UTF_8);
9595
}
9696
}

0 commit comments

Comments
 (0)