Skip to content

Commit

Permalink
Code review feedback.
Browse files Browse the repository at this point in the history
Still need to fix test failure.
  • Loading branch information
rxin committed Jun 11, 2015
1 parent 0967ce6 commit ffedb62
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.Arrays;
import javax.annotation.Nullable;

import org.apache.spark.unsafe.PlatformDependent;

/**
* A UTF-8 String for internal Spark use.
* <p>
Expand All @@ -35,7 +37,7 @@ public final class UTF8String implements Comparable<UTF8String>, Serializable {
@Nullable
private byte[] bytes;

private int[] bytesOfCodePointInUTF8 = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
private static int[] bytesOfCodePointInUTF8 = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
Expand Down Expand Up @@ -156,8 +158,10 @@ public String toString() {
try {
return new String(bytes, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "unsupported encoding";
// Turn the exception into unchecked so we can find out about it at runtime, but
// don't need to add lots of boilerplate code everywhere.
PlatformDependent.throwException(e);
return "unknown"; // we will never reach here.
}
}

Expand Down

0 comments on commit ffedb62

Please sign in to comment.