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
This commit is contained in:
Javen O'Neal 2016-09-21 02:45:39 +00:00
parent 29128d019d
commit 2be1834545
6 changed files with 23 additions and 16 deletions

View File

@ -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())

View File

@ -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
}

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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 List<String>logged = new ArrayList<String>();
@ -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);
}
}

View File

@ -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;
}