From 2be18345450c44f73b3aecde99250940a41cad87 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Wed, 21 Sep 2016 02:45:39 +0000 Subject: [PATCH] bug 59933: demote accessibility of POILogger implementations of log(int, Object) and log(int, Object, Throwable) to be consistent with the POILogger abstract class git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1761665 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/util/CommonsLogger.java | 12 +++++++++--- src/java/org/apache/poi/util/NullLogger.java | 4 ++-- src/java/org/apache/poi/util/POILogger.java | 8 ++++---- src/java/org/apache/poi/util/SystemOutLogger.java | 6 +++--- .../org/apache/poi/util/DummyPOILogger.java | 5 +++-- src/testcases/org/apache/poi/util/TestPOILogger.java | 4 ++-- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/java/org/apache/poi/util/CommonsLogger.java b/src/java/org/apache/poi/util/CommonsLogger.java index 1cbb9628c..bbb04af6d 100644 --- a/src/java/org/apache/poi/util/CommonsLogger.java +++ b/src/java/org/apache/poi/util/CommonsLogger.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; */ public class CommonsLogger extends POILogger { - private static LogFactory _creator = LogFactory.getFactory(); + private static final LogFactory _creator = LogFactory.getFactory(); private Log log = null; @Override @@ -46,8 +46,10 @@ public class CommonsLogger extends POILogger * @param obj1 The object to log. */ @Override - public void log(final int level, final Object obj1) + protected void log(final int level, final Object obj1) { + // FIXME: What happens if level is in between two levels (an even number)? + // Should this be `if (level >= FATAL) ...`? if(level==FATAL) { if(log.isFatalEnabled()) @@ -100,9 +102,11 @@ public class CommonsLogger extends POILogger * @param exception An exception to be logged */ @Override - public void log(final int level, final Object obj1, + protected void log(final int level, final Object obj1, final Throwable exception) { + // FIXME: What happens if level is in between two levels (an even number)? + // Should this be `if (level >= FATAL) ...`? if(level==FATAL) { if(log.isFatalEnabled()) @@ -174,6 +178,8 @@ public class CommonsLogger extends POILogger @Override public boolean check(final int level) { + // FIXME: What happens if level is in between two levels (an even number)? + // Should this be `if (level >= FATAL) ...`? if(level==FATAL) { if(log.isFatalEnabled()) diff --git a/src/java/org/apache/poi/util/NullLogger.java b/src/java/org/apache/poi/util/NullLogger.java index 8a50cffba..e21adfaa7 100644 --- a/src/java/org/apache/poi/util/NullLogger.java +++ b/src/java/org/apache/poi/util/NullLogger.java @@ -38,7 +38,7 @@ public class NullLogger extends POILogger { */ @Override - protected void log(final int level, final Object obj1) { + protected void _log(final int level, final Object obj1) { // do nothing } @@ -50,7 +50,7 @@ public class NullLogger extends POILogger { * @param exception An exception to be logged */ @Override - protected void log(int level, Object obj1, final Throwable exception) { + protected void _log(int level, Object obj1, final Throwable exception) { // do nothing } diff --git a/src/java/org/apache/poi/util/POILogger.java b/src/java/org/apache/poi/util/POILogger.java index 9238de01c..c54c75425 100644 --- a/src/java/org/apache/poi/util/POILogger.java +++ b/src/java/org/apache/poi/util/POILogger.java @@ -54,7 +54,7 @@ public abstract class POILogger { * @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param obj1 The object to log. This is converted to a string. */ - abstract protected void log(int level, Object obj1); + abstract protected void _log(int level, Object obj1); /** * Log a message @@ -63,7 +63,7 @@ public abstract class POILogger { * @param obj1 The object to log. This is converted to a string. * @param exception An exception to be logged */ - abstract protected void log(int level, Object obj1, final Throwable exception); + abstract protected void _log(int level, Object obj1, final Throwable exception); /** @@ -107,9 +107,9 @@ public abstract class POILogger { // somehow this ambiguity works and doesn't lead to a loop, // but it's confusing ... if (lastEx == null) { - log(level, msg); + _log(level, msg); } else { - log(level, msg, lastEx); + _log(level, msg, lastEx); } } } diff --git a/src/java/org/apache/poi/util/SystemOutLogger.java b/src/java/org/apache/poi/util/SystemOutLogger.java index 36d96ca03..457f25410 100644 --- a/src/java/org/apache/poi/util/SystemOutLogger.java +++ b/src/java/org/apache/poi/util/SystemOutLogger.java @@ -42,9 +42,9 @@ public class SystemOutLogger extends POILogger * @param obj1 The object to log. */ @Override - public void log(final int level, final Object obj1) + protected void _log(final int level, final Object obj1) { - log(level, obj1, null); + _log(level, obj1, null); } /** @@ -56,7 +56,7 @@ public class SystemOutLogger extends POILogger */ @Override @SuppressForbidden("uses printStackTrace") - public void log(final int level, final Object obj1, + protected void _log(final int level, final Object obj1, final Throwable exception) { if (check(level)) { System.out.println("[" + _cat + "]" + LEVEL_STRINGS_SHORT[Math.min(LEVEL_STRINGS_SHORT.length-1, level)] + " " + obj1); diff --git a/src/testcases/org/apache/poi/util/DummyPOILogger.java b/src/testcases/org/apache/poi/util/DummyPOILogger.java index c8566fe66..7da48ce26 100644 --- a/src/testcases/org/apache/poi/util/DummyPOILogger.java +++ b/src/testcases/org/apache/poi/util/DummyPOILogger.java @@ -23,6 +23,7 @@ import java.util.List; * POILogger which logs into an ArrayList, so that * tests can see what got logged */ +@Internal public class DummyPOILogger extends POILogger { public Listlogged = new ArrayList(); @@ -39,12 +40,12 @@ public class DummyPOILogger extends POILogger { public void initialize(String cat) {} @Override - public void log(int level, Object obj1) { + protected void _log(int level, Object obj1) { logged.add(level + " - " + obj1); } @Override - public void log(int level, Object obj1, Throwable exception) { + protected void _log(int level, Object obj1, Throwable exception) { logged.add(level + " - " + obj1 + " - " + exception); } } diff --git a/src/testcases/org/apache/poi/util/TestPOILogger.java b/src/testcases/org/apache/poi/util/TestPOILogger.java index 3914b7643..6650ed9e6 100644 --- a/src/testcases/org/apache/poi/util/TestPOILogger.java +++ b/src/testcases/org/apache/poi/util/TestPOILogger.java @@ -65,13 +65,13 @@ public final class TestPOILogger extends POILogger { } @Override - public void log(int level, Object obj1) { + protected void _log(int level, Object obj1) { lastLog = (obj1 == null) ? "" : obj1.toString(); lastEx = null; } @Override - public void log(int level, Object obj1, Throwable exception) { + protected void _log(int level, Object obj1, Throwable exception) { lastLog = (obj1 == null) ? "" : obj1.toString(); lastEx = exception; }