zzzk1 commented on code in PR #6354:
URL: https://github.com/apache/gravitino/pull/6354#discussion_r1926292078


##########
server-common/src/main/java/org/apache/gravitino/server/authentication/KerberosServerUtils.java:
##########
@@ -353,11 +354,7 @@ 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.
-      }

Review Comment:
   we can't do that, if we use:
    ```java
   try {
           return new String(bb.array(), bb.arrayOffset() + bb.position(), 
bb.remaining(), StandardCharsets.UTF_8);
         } catch (UnsupportedEncodingException e) {
           throw new IllegalCharsetNameException("UTF-8"); // won't happen.
         }
   ```
   
   the complier will report **Exception java.io.UnsupportedEncodingException is 
never thrown in the corresponding try block** like this:
   > <img width="870" alt="Screenshot 2025-01-23 at 10 53 59" 
src="https://github.com/user-attachments/assets/e40b00f8-7c10-4b68-8031-e9402f243ff7";
 />
   
   maybe we can use `Exception` replace `UnsupportedEncodingException`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to