HADOOP-16717. Remove GenericsUtil isLog4jLogger dependency on Log4jLoggerAdapter. Contributed by Xieming Li.

This commit is contained in:
Akira Ajisaka 2019-11-25 14:36:27 +09:00
parent 049940e77b
commit da9435182a
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50

View File

@ -25,7 +25,6 @@
import org.apache.hadoop.classification.InterfaceStability;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.impl.Log4jLoggerAdapter;
/**
* Contains utility methods for dealing with Java Generics.
@ -85,6 +84,11 @@ public static boolean isLog4jLogger(Class<?> clazz) {
return false;
}
Logger log = LoggerFactory.getLogger(clazz);
return log instanceof Log4jLoggerAdapter;
try {
Class log4jClass = Class.forName("org.slf4j.impl.Log4jLoggerAdapter");
return log4jClass.isInstance(log);
} catch (ClassNotFoundException e) {
return false;
}
}
}