diff --git a/server-common/src/main/java/org/apache/gravitino/server/authentication/KerberosServerUtils.java b/server-common/src/main/java/org/apache/gravitino/server/authentication/KerberosServerUtils.java index 3813b26bbfb..4db1a53bc28 100644 --- a/server-common/src/main/java/org/apache/gravitino/server/authentication/KerberosServerUtils.java +++ b/server-common/src/main/java/org/apache/gravitino/server/authentication/KerberosServerUtils.java @@ -16,12 +16,11 @@ import java.io.File; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; -import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -353,11 +352,8 @@ DER get(int... tags) { } String getAsString() { - try { - return new String(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining(), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalCharsetNameException("UTF-8"); // won't happen. - } + return new String( + bb.array(), bb.arrayOffset() + bb.position(), bb.remaining(), StandardCharsets.UTF_8); } @Override