Skip to content

Commit e25881e

Browse files
author
Justin Brinegar
committed
review feedback
1 parent 9541294 commit e25881e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/util/subject/GetSubjectNg.java renamed to hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/util/subject/GetSubjectJava18AndAbove.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
/**
2626
* Indirectly calls Subject.current(), which exists in Java 18 and above only
2727
*/
28-
class GetSubjectNg implements HiddenGetSubject {
28+
class GetSubjectJava18AndAbove implements HiddenGetSubject {
2929
private final Method currentMethod;
3030

31-
GetSubjectNg() {
31+
GetSubjectJava18AndAbove() {
3232
try {
3333
currentMethod = Subject.class.getMethod("current");
3434
} catch (NoSuchMethodException e) {

hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/util/subject/SubjectAdapter.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
package org.apache.hadoop.util.subject;
2020

21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
23+
2124
import javax.security.auth.Subject;
2225

2326
/**
@@ -26,14 +29,15 @@
2629
* This class helps use the newer API if available, without raising the language level.
2730
*/
2831
public class SubjectAdapter {
32+
private static Logger log = LoggerFactory.getLogger(SubjectAdapter.class);
2933
private static final HiddenGetSubject instance;
3034
static {
3135
int version = 0;
3236
try {
3337
version = Integer.parseInt(System.getProperty("java.specification.version"));
3438
} catch (Throwable ignored) {}
3539
if (version >= 18) {
36-
instance = new GetSubjectNg();
40+
instance = new GetSubjectJava18AndAbove();
3741
} else {
3842
instance = new ClassicGetSubject();
3943
}
@@ -45,8 +49,12 @@ public static Subject getSubject() {
4549
return instance.getSubject();
4650
}
4751

48-
// the main is included so that this is trivially tested using multiple JDKs outside the scope of test sources
52+
/**
53+
* This main method is included so that this is trivially tested using multiple JDKs outside the scope test sources
54+
* @param args ignored
55+
*/
4956
public static void main(String[] args) {
50-
System.out.println("Current subject is " + getSubject());
57+
final Subject theSubject = getSubject();
58+
log.info("Current subject is {}", theSubject);
5159
}
5260
}

0 commit comments

Comments
 (0)