roryqi commented on code in PR #10052:
URL: https://github.com/apache/gravitino/pull/10052#discussion_r3009196467


##########
clients/client-java/src/main/java/org/apache/gravitino/client/KerberosTokenProvider.java:
##########
@@ -349,5 +350,39 @@ private void extractPrincipalFromSubject(Subject subject) {
               .map(Object::toString)
               .orElse(null);
     }
+
+    /**
+     * Returns the current {@link Subject} in a JDK-version-neutral way.
+     *
+     * <ul>
+     *   <li>JDK 18+: uses {@code Subject.current()} via reflection, which is 
the designated
+     *       replacement for the removed {@code 
Subject.getSubject(AccessControlContext)}
+     *   <li>JDK 17 and below: uses the deprecated {@code 
Subject.getSubject(AccessControlContext)}
+     * </ul>
+     *
+     * @return the current Subject, or {@code null} if none is established
+     */
+    @SuppressWarnings("removal")
+    private static Subject getCurrentSubject() {
+      // Use reflection to call Subject.current() (JDK 18+) because this 
project compiles on
+      // JDK 17, where Subject.current() does not exist as a compile-time API.
+      // Fall back to the deprecated Subject.getSubject(AccessControlContext) 
on JDK 17 and below.
+      try {
+        java.lang.reflect.Method currentMethod = 
Subject.class.getMethod("current");

Review Comment:
   Could u use the short name?



-- 
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