Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions log4j-1.2-api/src/main/java/org/apache/log4j/Hierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.log4j;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
Expand Down Expand Up @@ -79,10 +80,16 @@ protected Logger newLogger(final String name, final org.apache.logging.log4j.spi
private static class PrivateLogManager extends org.apache.logging.log4j.LogManager {
private static final String FQCN = Hierarchy.class.getName();

@SuppressFBWarnings(
value = "HSM_HIDING_METHOD",
justification = "The class is private, no confusion can arise.")
public static LoggerContext getContext() {
return getContext(FQCN, false);
}

@SuppressFBWarnings(
value = "HSM_HIDING_METHOD",
justification = "The class is private, no confusion can arise.")
public static org.apache.logging.log4j.Logger getLogger(final String name) {
return getLogger(FQCN, name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class LogEventAdapter extends LoggingEvent {

private static final long JVM_START_TIME = initStartTime();
public static final long JVM_START_TIME = initStartTime();

private final LogEvent event;

Expand All @@ -50,7 +50,7 @@ public LogEventAdapter(final LogEvent event) {
* elapsed since 01.01.1970.
* @return the time when the JVM started.
*/
public static long getStartTime() {
public static long getJvmStartTime() {
return JVM_START_TIME;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.apache.logging.log4j.util.Strings.toRootUpperCase;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Level;
Expand Down Expand Up @@ -157,6 +158,7 @@ public static UtilLoggingLevel toLevel(final int val, final UtilLoggingLevel def
* @param val numeric value.
* @return matching level or UtilLoggerLevel.FINEST if no match.
*/
@SuppressFBWarnings(value = "HSM_HIDING_METHOD", justification = "Legacy code")
public static Level toLevel(final int val) {
return toLevel(val, FINEST);
}
Expand Down Expand Up @@ -184,6 +186,7 @@ public static List getAllPossibleLevels() {
* @param s symbolic name.
* @return matching level or Level.DEBUG if no match.
*/
@SuppressFBWarnings(value = "HSM_HIDING_METHOD", justification = "Legacy code")
public static Level toLevel(final String s) {
return toLevel(s, Level.DEBUG);
}
Expand All @@ -195,6 +198,7 @@ public static Level toLevel(final String s) {
* @param defaultLevel level to return if no match.
* @return matching level or defaultLevel if no match.
*/
@SuppressFBWarnings(value = "HSM_HIDING_METHOD", justification = "Legacy code")
public static Level toLevel(final String sArg, final Level defaultLevel) {
if (sArg == null) {
return defaultLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Log4j 1.x compatibility layer.
*/
@Export
@Version("2.20.2")
@Version("2.20.3")
package org.apache.log4j.helpers;

import org.osgi.annotation.bundle.Export;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LoggingEvent {
* @return the JVM start time.
*/
public static long getStartTime() {
return LogEventAdapter.getStartTime();
return LogEventAdapter.getJvmStartTime();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.appserver.jetty;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.spi.ExtendedLogger;
Expand Down Expand Up @@ -51,6 +52,7 @@ public class Log4j2Logger extends AbstractLogger {
*/
private static class PrivateManager extends LogManager {

@SuppressFBWarnings("HSM_HIDING_METHOD")
public static LoggerContext getContext() {
final ClassLoader cl = AbstractLogger.class.getClassLoader();
return getContext(PARENT_FQCN, cl, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -163,6 +164,7 @@ public void fatal(final Object o, final Throwable throwable) {
*/
private static class PrivateManager extends LogManager {

@SuppressFBWarnings("HSM_HIDING_METHOD")
public static LoggerContext getContext() {
final ClassLoader cl = TomcatLogger.class.getClassLoader();
URI uri = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.async;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -90,7 +91,7 @@ public LoggerConfig build() {
isAdditivity(),
getProperties(),
getConfig(),
includeLocation(getIncludeLocation()));
shouldIncludeLocation(getIncludeLocation()));
}
}

Expand Down Expand Up @@ -273,7 +274,14 @@ public static LoggerConfig createLogger(
final boolean additive = Booleans.parseBoolean(additivity, true);

return new AsyncLoggerConfig(
name, appenderRefs, filter, level, additive, properties, config, includeLocation(includeLocation));
name,
appenderRefs,
filter,
level,
additive,
properties,
config,
shouldIncludeLocation(includeLocation));
}

/**
Expand All @@ -291,6 +299,7 @@ public static LoggerConfig createLogger(
* @since 3.0
*/
@Deprecated
@SuppressFBWarnings("HSM_HIDING_METHOD")
public static LoggerConfig createLogger(
@PluginAttribute(value = "additivity", defaultBoolean = true) final boolean additivity,
@PluginAttribute("level") final Level level,
Expand All @@ -310,11 +319,20 @@ public static LoggerConfig createLogger(
additivity,
properties,
config,
includeLocation(includeLocation));
shouldIncludeLocation(includeLocation));
}

// Note: for asynchronous loggers, includeLocation default is FALSE
/**
* @deprecated since 2.25.0. The method will become private in version 3.0.
*/
@Deprecated
@SuppressFBWarnings(value = "HSM_HIDING_METHOD", justification = "Should be private.")
protected static boolean includeLocation(final String includeLocationConfigValue) {
return shouldIncludeLocation(includeLocationConfigValue);
}

// Note: for asynchronous loggers, includeLocation default is FALSE
private static boolean shouldIncludeLocation(final String includeLocationConfigValue) {
return Boolean.parseBoolean(includeLocationConfigValue);
}

Expand Down Expand Up @@ -343,7 +361,7 @@ public LoggerConfig build() {
isAdditivity(),
getProperties(),
getConfig(),
AsyncLoggerConfig.includeLocation(getIncludeLocation()));
shouldIncludeLocation(getIncludeLocation()));
}
}

Expand Down Expand Up @@ -376,7 +394,7 @@ public static LoggerConfig createLogger(
additive,
properties,
config,
AsyncLoggerConfig.includeLocation(includeLocation));
shouldIncludeLocation(includeLocation));
}

/**
Expand All @@ -402,7 +420,7 @@ public static LoggerConfig createLogger(
additive,
properties,
config,
AsyncLoggerConfig.includeLocation(includeLocation));
shouldIncludeLocation(includeLocation));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.lookup;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
Expand Down Expand Up @@ -74,6 +75,9 @@ public MainMapLookup(final Map<String, String> map) {
* @param args
* An application's {@code public static main(String[])} arguments.
*/
@SuppressFBWarnings(
value = "HSM_HIDING_METHOD",
justification = "The MapLookup.setMainArguments() method hidden by this one is deprecated.")
public static void setMainArguments(final String... args) {
if (args == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* {@link org.apache.logging.log4j.core.lookup.StrLookup#CATEGORY Lookup}.
*/
@Export
@Version("2.24.0")
@Version("2.24.1")
package org.apache.logging.log4j.core.lookup;

import org.osgi.annotation.bundle.Export;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ Throwable extractThrowable(final LogEvent logEvent) {
return logEvent.getThrown();
}

static String getName() {
return "exception";
}

@Override
public boolean isResolvable() {
return stackTraceEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static ExceptionResolverFactory getInstance() {

@Override
public String getName() {
return ExceptionResolver.getName();
return "exception";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public final class ExceptionRootCauseResolver extends ExceptionResolver {
super(context, config);
}

static String getName() {
return "exceptionRootCause";
}

@Override
Throwable extractThrowable(final LogEvent logEvent) {
final Throwable thrown = logEvent.getThrown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static ExceptionRootCauseResolverFactory getInstance() {

@Override
public String getName() {
return ExceptionRootCauseResolver.getName();
return "exceptionRootCause";
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions src/changelog/.2.x.x/3601_deprecate_or_remove_hiding_methods.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="3601" link="https://github.com/apache/logging-log4j2/issues/3601"/>
<description format="asciidoc">
Deprecate or remove static hiding methods.
</description>
</entry>