From da9435182a8fccec743406e089325655138d9de8 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Mon, 25 Nov 2019 14:36:27 +0900 Subject: [PATCH] HADOOP-16717. Remove GenericsUtil isLog4jLogger dependency on Log4jLoggerAdapter. Contributed by Xieming Li. --- .../main/java/org/apache/hadoop/util/GenericsUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericsUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericsUtil.java index a53096a957..0aba34845a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericsUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/GenericsUtil.java @@ -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; + } } }