From f2aba1da30aae482a2d65696493b609948f9b904 Mon Sep 17 00:00:00 2001 From: Wenxin He Date: Tue, 27 Jun 2017 11:51:34 +0800 Subject: [PATCH] HADOOP-14571. Deprecate public APIs relate to log4j1 This closes #244 Signed-off-by: Akira Ajisaka --- .../java/org/apache/hadoop/io/IOUtils.java | 3 ++ .../org/apache/hadoop/util/LogAdapter.java | 4 +++ .../apache/hadoop/test/GenericTestUtils.java | 33 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java index e24f1960acc..a3bccef398c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java @@ -246,7 +246,10 @@ public class IOUtils { * * @param log the log to record problems to at debug level. Can be null. * @param closeables the objects to close + * @deprecated use {@link #cleanupWithLogger(Logger, java.io.Closeable...)} + * instead */ + @Deprecated public static void cleanup(Log log, java.io.Closeable... closeables) { for (java.io.Closeable c : closeables) { if (c != null) { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LogAdapter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LogAdapter.java index 6ef9093a282..b2bcbf57ef2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LogAdapter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LogAdapter.java @@ -32,6 +32,10 @@ class LogAdapter { this.LOGGER = LOGGER; } + /** + * @deprecated use {@link #create(Logger)} instead + */ + @Deprecated public static LogAdapter create(Log LOG) { return new LogAdapter(LOG); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java index 00dc7f2b40c..77a79ff140c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java @@ -94,20 +94,33 @@ public abstract class GenericTestUtils { public static final String ERROR_INVALID_ARGUMENT = "Total wait time should be greater than check interval time"; + /** + * @deprecated use {@link #disableLog(org.slf4j.Logger)} instead + */ + @Deprecated @SuppressWarnings("unchecked") public static void disableLog(Log log) { // We expect that commons-logging is a wrapper around Log4j. disableLog((Log4JLogger) log); } + @Deprecated public static Logger toLog4j(org.slf4j.Logger logger) { return LogManager.getLogger(logger.getName()); } + /** + * @deprecated use {@link #disableLog(org.slf4j.Logger)} instead + */ + @Deprecated public static void disableLog(Log4JLogger log) { log.getLogger().setLevel(Level.OFF); } + /** + * @deprecated use {@link #disableLog(org.slf4j.Logger)} instead + */ + @Deprecated public static void disableLog(Logger logger) { logger.setLevel(Level.OFF); } @@ -116,20 +129,40 @@ public abstract class GenericTestUtils { disableLog(toLog4j(logger)); } + /** + * @deprecated + * use {@link #setLogLevel(org.slf4j.Logger, org.slf4j.event.Level)} instead + */ + @Deprecated @SuppressWarnings("unchecked") public static void setLogLevel(Log log, Level level) { // We expect that commons-logging is a wrapper around Log4j. setLogLevel((Log4JLogger) log, level); } + /** + * @deprecated + * use {@link #setLogLevel(org.slf4j.Logger, org.slf4j.event.Level)} instead + */ + @Deprecated public static void setLogLevel(Log4JLogger log, Level level) { log.getLogger().setLevel(level); } + /** + * @deprecated + * use {@link #setLogLevel(org.slf4j.Logger, org.slf4j.event.Level)} instead + */ + @Deprecated public static void setLogLevel(Logger logger, Level level) { logger.setLevel(level); } + /** + * @deprecated + * use {@link #setLogLevel(org.slf4j.Logger, org.slf4j.event.Level)} instead + */ + @Deprecated public static void setLogLevel(org.slf4j.Logger logger, Level level) { setLogLevel(toLog4j(logger), level); }