File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
network/common/src/main/java/org/apache/spark/network/util Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 2929
3030import com .google .common .io .Closeables ;
3131import com .google .common .base .Charsets ;
32+ import io .netty .buffer .Unpooled ;
3233import org .slf4j .Logger ;
3334import org .slf4j .LoggerFactory ;
3435
@@ -83,14 +84,14 @@ public static int nonNegativeHash(Object obj) {
8384 * converted back to the same string through {@link #bytesToString(ByteBuffer)}.
8485 */
8586 public static ByteBuffer stringToBytes (String s ) {
86- return ByteBuffer . wrap (s .getBytes (Charsets .UTF_8 ));
87+ return Unpooled . wrappedBuffer (s .getBytes (Charsets .UTF_8 )). nioBuffer ( );
8788 }
8889
8990 /**
9091 * Convert the given byte buffer to a string. The resulting string can be
9192 * converted back to the same byte buffer through {@link #stringToBytes(String)}.
9293 */
9394 public static String bytesToString (ByteBuffer b ) {
94- return new String ( b . array (), Charsets .UTF_8 );
95+ return Unpooled . wrappedBuffer ( b ). toString ( Charsets .UTF_8 );
9596 }
9697}
You can’t perform that action at this time.
0 commit comments