Skip to content

Bump org.apache.logging:logging-parent from 10.5.0 to 10.6.0 #2193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
8 changes: 1 addition & 7 deletions log4j-1.2-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<version>${revision}</version>
<relativePath>../log4j-parent</relativePath>
</parent>

<artifactId>log4j-1.2-api</artifactId>
<packaging>jar</packaging>
<name>Apache Log4j 1.x Compatibility API</name>
Expand Down Expand Up @@ -86,12 +85,6 @@
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
<!-- Place Felix before Equinox because Felix is signed. -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
Expand All @@ -107,6 +100,7 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<!-- JUnit -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down
43 changes: 6 additions & 37 deletions log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.apache.log4j.helpers.AppenderAttachableImpl;
import org.apache.log4j.helpers.NullEnumeration;
import org.apache.log4j.legacy.core.CategoryUtil;
import org.apache.log4j.or.ObjectRenderer;
import org.apache.log4j.or.RendererMap;
import org.apache.log4j.spi.AppenderAttachable;
import org.apache.log4j.spi.HierarchyEventListener;
import org.apache.log4j.spi.LoggerRepository;
Expand Down Expand Up @@ -144,8 +142,6 @@ public static void shutdown() {
*/
protected volatile Level level;

private RendererMap rendererMap;

/**
* The parent of this category. All categories have at least one ancestor which is the root category.
*/
Expand All @@ -172,7 +168,6 @@ public static void shutdown() {
protected Category(final LoggerContext context, final String name) {
this.name = name;
this.logger = context.getLogger(name);
this.repository = LogManager.getLoggerRepository();
}

Category(final org.apache.logging.log4j.Logger logger) {
Expand Down Expand Up @@ -345,21 +340,6 @@ public void forcedLog(final String fqcn, final Priority level, final Object mess
}
}

private <T> ObjectRenderer get(final Class<T> clazz) {
ObjectRenderer renderer = null;
for (Class<? super T> c = clazz; c != null; c = c.getSuperclass()) {
renderer = rendererMap.get(c);
if (renderer != null) {
return renderer;
}
renderer = searchInterfaces(c);
if (renderer != null) {
return renderer;
}
}
return null;
}

public boolean getAdditivity() {
return LogManager.isLog4jCorePresent() ? CategoryUtil.isAdditive(logger) : false;
}
Expand Down Expand Up @@ -471,8 +451,12 @@ public final Category getParent() {
return null;
}
final ConcurrentMap<String, Logger> loggers = Hierarchy.getLoggersMap(loggerContext);
final Logger parentLogger = loggers.get(parent.getName());
return parentLogger == null ? new Category(parent) : parentLogger;
Category parentLogger = loggers.get(parent.getName());
if (parentLogger == null) {
parentLogger = new Category(parent);
parentLogger.setHierarchy(getLoggerRepository());
}
return parentLogger;
}

public final Level getPriority() {
Expand Down Expand Up @@ -653,21 +637,6 @@ public void removeAppender(final String name) {
}
}

ObjectRenderer searchInterfaces(final Class<?> c) {
ObjectRenderer renderer = rendererMap.get(c);
if (renderer != null) {
return renderer;
}
final Class<?>[] ia = c.getInterfaces();
for (final Class<?> clazz : ia) {
renderer = searchInterfaces(clazz);
if (renderer != null) {
return renderer;
}
}
return null;
}

public void setAdditivity(final boolean additivity) {
if (LogManager.isLog4jCorePresent()) {
CategoryUtil.setAdditivity(logger, additivity);
Expand Down
22 changes: 13 additions & 9 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 @@ -96,16 +96,24 @@ static LoggerContext getContext() {
return PrivateLogManager.getContext();
}

static Logger getInstance(final LoggerContext context, final String name) {
private Logger getInstance(final LoggerContext context, final String name) {
return getInstance(context, name, LOGGER_ADAPTER);
}

static Logger getInstance(final LoggerContext context, final String name, final LoggerFactory factory) {
return getLoggersMap(context).computeIfAbsent(name, k -> factory.makeNewLoggerInstance(name));
private Logger getInstance(final LoggerContext context, final String name, final LoggerFactory factory) {
return getLoggersMap(context).computeIfAbsent(name, k -> {
final Logger logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
return logger;
});
}

static Logger getInstance(final LoggerContext context, final String name, final PrivateLoggerAdapter factory) {
return getLoggersMap(context).computeIfAbsent(name, k -> factory.newLogger(name, context));
private Logger getInstance(final LoggerContext context, final String name, final PrivateLoggerAdapter factory) {
return getLoggersMap(context).computeIfAbsent(name, k -> {
final Logger logger = factory.newLogger(name, context);
logger.setHierarchy(this);
return logger;
});
}

static ConcurrentMap<String, Logger> getLoggersMap(final LoggerContext context) {
Expand All @@ -114,10 +122,6 @@ static ConcurrentMap<String, Logger> getLoggersMap(final LoggerContext context)
}
}

static Logger getRootLogger(final LoggerContext context) {
return getInstance(context, org.apache.logging.log4j.LogManager.ROOT_LOGGER_NAME);
}

private final LoggerFactory defaultFactory;
private final Vector listeners;
Hashtable ht;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import org.apache.log4j.helpers.QuietWriter;
import org.apache.log4j.spi.ErrorHandler;
Expand Down Expand Up @@ -235,12 +236,8 @@ protected OutputStreamWriter createWriter(final OutputStream os) {
if (enc != null) {
try {
retval = new OutputStreamWriter(os, enc);
} catch (IOException e) {
if (e instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
LOGGER.warn("Error initializing output writer.");
LOGGER.warn("Unsupported encoding?");
} catch (final UnsupportedEncodingException e) {
LOGGER.warn("Error initializing output writer: encoding {} is not supported.", enc, e);
}
}
if (retval == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.log4j.bridge.FilterAdapter;
import org.apache.log4j.bridge.FilterWrapper;
Expand Down Expand Up @@ -121,6 +122,19 @@ public int getIntegerProperty(final String key, final int defaultValue) {
return defaultValue;
}

public long getLongProperty(final String key, final long defaultValue) {
String value = null;
try {
value = getProperty(key);
if (value != null) {
return Long.parseLong(value);
}
} catch (final Exception ex) {
LOGGER.warn("Error converting value {} of {} to a long: {}", value, key, ex.getMessage());
}
return defaultValue;
}

protected String getNameAttribute(final Element element) {
return element.getAttribute(NAME_ATTR);
}
Expand Down Expand Up @@ -202,6 +216,25 @@ protected void set(final String name, final Element element, final AtomicInteger
}
}

protected void set(final String name, final Element element, final AtomicLong ref) {
final String value = getValueAttribute(element);
if (value == null) {
LOGGER.warn("No value for {} parameter, using default {}", name, ref);
} else {
try {
ref.set(Long.parseLong(value));
} catch (NumberFormatException e) {
LOGGER.warn(
"{} parsing {} parameter, using default {}: {}",
e.getClass().getName(),
name,
ref,
e.getMessage(),
e);
}
}
}

protected void set(final String name, final Element element, final AtomicReference<String> ref) {
final String value = getValueAttribute(element);
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import org.apache.log4j.builders.filter.FilterBuilder;
import org.apache.log4j.builders.layout.LayoutBuilder;
import org.apache.log4j.builders.rewrite.RewritePolicyBuilder;
import org.apache.log4j.builders.rolling.TriggeringPolicyBuilder;
import org.apache.log4j.config.PropertiesConfiguration;
import org.apache.log4j.rewrite.RewritePolicy;
import org.apache.log4j.spi.Filter;
import org.apache.log4j.xml.XmlConfiguration;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
import org.apache.logging.log4j.plugins.Inject;
import org.apache.logging.log4j.plugins.Namespace;
import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory;
Expand Down Expand Up @@ -67,7 +69,7 @@ public class BuilderManager {
*/
@Inject
public BuilderManager(
final ConfigurableInstanceFactory instanceFactory, @Namespace(NAMESPACE) PluginNamespace plugins) {
final ConfigurableInstanceFactory instanceFactory, @Namespace(NAMESPACE) final PluginNamespace plugins) {
this.instanceFactory = instanceFactory;
this.plugins = plugins;
}
Expand Down Expand Up @@ -124,7 +126,7 @@ public <P extends Parser<T>, T> T parse(
final String prefix,
final Properties props,
final PropertiesConfiguration config,
T invalidValue) {
final T invalidValue) {
final P parser = createBuilder(getPlugin(className), prefix, props);
if (parser != null) {
final T value = parser.parse(config);
Expand Down Expand Up @@ -174,4 +176,12 @@ public RewritePolicy parseRewritePolicy(
b -> b.parse(rewriteElement, config),
INVALID_REWRITE_POLICY);
}

public TriggeringPolicy parseTriggeringPolicy(
final String className, final Element policyElement, final XmlConfiguration config) {
return newInstance(
this.<TriggeringPolicyBuilder>getPlugin(className),
b -> b.parse(policyElement, config),
(TriggeringPolicy) null);
}
}
Loading