Skip to content

Commit 2cb3c69

Browse files
committed
Use utf-8 encoding in set bytes.
1 parent 53f8ef4 commit 2cb3c69

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ public static UTF8String fromString(String str) {
5656
* Updates the UTF8String with String.
5757
*/
5858
public UTF8String set(final String str) {
59-
bytes = str.getBytes();
59+
try {
60+
bytes = str.getBytes("utf-8");
61+
} catch (UnsupportedEncodingException e) {
62+
// Turn the exception into unchecked so we can find out about it at runtime, but
63+
// don't need to add lots of boilerplate code everywhere.
64+
PlatformDependent.throwException(e);
65+
}
6066
return this;
6167
}
6268

0 commit comments

Comments
 (0)