Update to version 3.5.1.Final

* Requires switching parent POM
* Requires regeneration of the two existing  patches
* A new patch is required to drop a test that depends on a package
that was retired from Fedora
This commit is contained in:
Chris Kelley 2023-06-06 21:38:02 +01:00
parent 1ab8b8fe4c
commit ad76d3b38d
5 changed files with 1271 additions and 408 deletions

View File

@ -1,332 +0,0 @@
From 83f101442cc126dab0ff4bf793f4ed518ff5df19 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Fri, 4 Jun 2021 13:17:33 -0500
Subject: [PATCH] Drop jboss-logmanager dependency
---
pom.xml | 7 -
.../jboss/logging/JBossLogManagerLogger.java | 78 ---------
.../logging/JBossLogManagerProvider.java | 150 ------------------
.../org/jboss/logging/LoggerProviders.java | 21 +--
4 files changed, 1 insertion(+), 255 deletions(-)
delete mode 100644 src/main/java/org/jboss/logging/JBossLogManagerLogger.java
delete mode 100644 src/main/java/org/jboss/logging/JBossLogManagerProvider.java
diff --git a/pom.xml b/pom.xml
index 88af23f..03e036c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,17 +31,10 @@
<properties>
<!-- Dependency versions -->
- <version.org.jboss.logmanager>2.1.9.Final</version.org.jboss.logmanager>
<version.org.sfl4j>1.7.25</version.org.sfl4j>
</properties>
<dependencies>
- <dependency>
- <groupId>org.jboss.logmanager</groupId>
- <artifactId>jboss-logmanager</artifactId>
- <version>${version.org.jboss.logmanager}</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
diff --git a/src/main/java/org/jboss/logging/JBossLogManagerLogger.java b/src/main/java/org/jboss/logging/JBossLogManagerLogger.java
deleted file mode 100644
index e4242cf..0000000
--- a/src/main/java/org/jboss/logging/JBossLogManagerLogger.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2010 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.jboss.logging;
-
-import org.jboss.logmanager.ExtLogRecord;
-
-final class JBossLogManagerLogger extends Logger {
-
- private static final long serialVersionUID = 7429618317727584742L;
-
- private final org.jboss.logmanager.Logger logger;
-
- JBossLogManagerLogger(final String name, final org.jboss.logmanager.Logger logger) {
- super(name);
- this.logger = logger;
- }
-
- public boolean isEnabled(final Level level) {
- return logger.isLoggable(translate(level));
- }
-
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
- java.util.logging.Level translatedLevel = translate(level);
- if (logger.isLoggable(translatedLevel)) {
- if (parameters == null) {
- logger.log(loggerClassName, translatedLevel, String.valueOf(message), thrown);
- } else {
- logger.log(loggerClassName, translatedLevel, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT, parameters, thrown);
- }
- }
- }
-
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) {
- if (parameters == null) {
- logger.log(loggerClassName, translate(level), format, thrown);
- } else {
- logger.log(loggerClassName, translate(level), format, ExtLogRecord.FormatStyle.PRINTF, parameters, thrown);
- }
- }
-
- private static java.util.logging.Level translate(final Level level) {
- if (level == Level.TRACE) {
- return org.jboss.logmanager.Level.TRACE;
- } else if (level == Level.DEBUG) {
- return org.jboss.logmanager.Level.DEBUG;
- }
- return infoOrHigher(level);
- }
-
- private static java.util.logging.Level infoOrHigher(final Level level) {
- if (level == Level.INFO) {
- return org.jboss.logmanager.Level.INFO;
- } else if (level == Level.WARN) {
- return org.jboss.logmanager.Level.WARN;
- } else if (level == Level.ERROR) {
- return org.jboss.logmanager.Level.ERROR;
- } else if (level == Level.FATAL) {
- return org.jboss.logmanager.Level.FATAL;
- }
- return org.jboss.logmanager.Level.ALL;
- }
-}
diff --git a/src/main/java/org/jboss/logging/JBossLogManagerProvider.java b/src/main/java/org/jboss/logging/JBossLogManagerProvider.java
deleted file mode 100644
index 6cdbce3..0000000
--- a/src/main/java/org/jboss/logging/JBossLogManagerProvider.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2010 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.jboss.logmanager.LogContext;
-import org.jboss.logmanager.MDC;
-import org.jboss.logmanager.NDC;
-
-import static org.jboss.logmanager.Logger.AttachmentKey;
-
-final class JBossLogManagerProvider implements LoggerProvider {
-
- private static final AttachmentKey<Logger> KEY = new AttachmentKey<Logger>();
- private static final AttachmentKey<ConcurrentMap<String, Logger>> LEGACY_KEY = new AttachmentKey<ConcurrentMap<String, Logger>>();
-
- public Logger getLogger(final String name) {
- final SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- return AccessController.doPrivileged(new PrivilegedAction<Logger>() {
- public Logger run() {
- try {
- return doGetLogger(name) ;
- } catch (NoSuchMethodError ignore) {
- }
- // fallback
- return doLegacyGetLogger(name);
- }
- });
- } else {
- try {
- return doGetLogger(name) ;
- } catch (NoSuchMethodError ignore) {
- }
- // fallback
- return doLegacyGetLogger(name);
- }
- }
-
- private static Logger doLegacyGetLogger(final String name) {
- final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger("");
- ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY);
- if (loggers == null) {
- loggers = new ConcurrentHashMap<String, Logger>();
- final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers);
- if (appearing != null) {
- loggers = appearing;
- }
- }
-
- Logger l = loggers.get(name);
- if (l != null) {
- return l;
- }
-
- final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name);
- l = new JBossLogManagerLogger(name, logger);
- final Logger appearing = loggers.putIfAbsent(name, l);
- if (appearing == null) {
- return l;
- }
- return appearing;
- }
-
- private static Logger doGetLogger(final String name) {
- Logger l = LogContext.getLogContext().getAttachment(name, KEY);
- if (l != null) {
- return l;
- }
- final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name);
- l = new JBossLogManagerLogger(name, logger);
- Logger a = logger.attachIfAbsent(KEY, l);
- if (a == null) {
- return l;
- } else {
- return a;
- }
- }
-
- public void clearMdc() {
- MDC.clear();
- }
-
- public Object putMdc(final String key, final Object value) {
- return MDC.put(key, String.valueOf(value));
- }
-
- public Object getMdc(final String key) {
- return MDC.get(key);
- }
-
- public void removeMdc(final String key) {
- MDC.remove(key);
- }
-
- @SuppressWarnings({ "unchecked" })
- public Map<String, Object> getMdcMap() {
- // we can re-define the erasure of this map because MDC does not make further use of the copy
- return (Map)MDC.copy();
- }
-
- public void clearNdc() {
- NDC.clear();
- }
-
- public String getNdc() {
- return NDC.get();
- }
-
- public int getNdcDepth() {
- return NDC.getDepth();
- }
-
- public String popNdc() {
- return NDC.pop();
- }
-
- public String peekNdc() {
- return NDC.get();
- }
-
- public void pushNdc(final String message) {
- NDC.push(message);
- }
-
- public void setNdcMaxDepth(final int maxDepth) {
- NDC.trimTo(maxDepth);
- }
-}
diff --git a/src/main/java/org/jboss/logging/LoggerProviders.java b/src/main/java/org/jboss/logging/LoggerProviders.java
index 8e393d1..2e8c994 100644
--- a/src/main/java/org/jboss/logging/LoggerProviders.java
+++ b/src/main/java/org/jboss/logging/LoggerProviders.java
@@ -21,7 +21,6 @@ package org.jboss.logging;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
-import java.util.logging.LogManager;
final class LoggerProviders {
static final String LOGGING_PROVIDER_KEY = "org.jboss.logging.provider";
@@ -41,9 +40,7 @@ final class LoggerProviders {
// Check the system property
final String loggerProvider = SecurityActions.getSystemProperty(LOGGING_PROVIDER_KEY);
if (loggerProvider != null) {
- if ("jboss".equalsIgnoreCase(loggerProvider)) {
- return tryJBossLogManager(cl, "system property");
- } else if ("jdk".equalsIgnoreCase(loggerProvider)) {
+ if ("jdk".equalsIgnoreCase(loggerProvider)) {
return tryJDK("system property");
} else if ("slf4j".equalsIgnoreCase(loggerProvider)) {
return trySlf4j("system property");
@@ -71,11 +68,6 @@ final class LoggerProviders {
}
// Finally search the class path
- try {
- return tryJBossLogManager(cl, null);
- } catch (Throwable t) {
- // nope...
- }
try {
// only use slf4j if Logback is in use
Class.forName("ch.qos.logback.classic.Logger", false, cl);
@@ -98,17 +90,6 @@ final class LoggerProviders {
return provider;
}
- private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException {
- final Class<? extends LogManager> logManagerClass = LogManager.getLogManager().getClass();
- if (logManagerClass == Class.forName("org.jboss.logmanager.LogManager", false, cl)
- && Class.forName("org.jboss.logmanager.Logger$AttachmentKey", true, cl).getClassLoader() == logManagerClass.getClassLoader()) {
- final LoggerProvider provider = new JBossLogManagerProvider();
- logProvider(provider, via);
- return provider;
- }
- throw new IllegalStateException();
- }
-
private static void logProvider(final LoggerProvider provider, final String via) {
// Log a debug message indicating which logger we are using
final Logger logger = provider.getLogger(LoggerProviders.class.getPackage().getName());
--
2.31.1

View File

@ -1,35 +1,43 @@
From db9a311cb2bf17f9febdf5e31d28ca83af399cf9 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Fri, 4 Jun 2021 12:20:45 -0500
Subject: [PATCH] Drop log4j dependency
From 838c62da9c65a917fe7d40c46639a36a8ed823a1 Mon Sep 17 00:00:00 2001
From: Chris Kelley <ckelley@redhat.com>
Date: Tue, 6 Jun 2023 12:04:45 +0100
Subject: [PATCH 1/3] Drop log4j dependency
---
pom.xml | 25 -----
.../java/org/jboss/logging/Log4j2Logger.java | 92 ------------------
.../jboss/logging/Log4j2LoggerProvider.java | 96 -------------------
.../java/org/jboss/logging/Log4jLogger.java | 74 --------------
.../jboss/logging/Log4jLoggerProvider.java | 86 -----------------
.../org/jboss/logging/LoggerProviders.java | 36 -------
6 files changed, 409 deletions(-)
pom.xml | 31 ----
.../java/org/jboss/logging/Log4j2Logger.java | 99 -----------
.../jboss/logging/Log4j2LoggerProvider.java | 102 ------------
.../java/org/jboss/logging/Log4jLogger.java | 82 ---------
.../jboss/logging/Log4jLoggerProvider.java | 105 ------------
.../org/jboss/logging/LoggerProviders.java | 36 ----
.../logging/Log4j2ClassPathTestCase.java | 30 ----
.../jboss/logging/Log4j2ProviderTestCase.java | 155 ------------------
.../jboss/logging/Log4jClassPathTestCase.java | 30 ----
.../jboss/logging/Log4jProviderTestCase.java | 137 ----------------
10 files changed, 807 deletions(-)
delete mode 100644 src/main/java/org/jboss/logging/Log4j2Logger.java
delete mode 100644 src/main/java/org/jboss/logging/Log4j2LoggerProvider.java
delete mode 100644 src/main/java/org/jboss/logging/Log4jLogger.java
delete mode 100644 src/main/java/org/jboss/logging/Log4jLoggerProvider.java
delete mode 100644 src/test/java/org/jboss/logging/Log4j2ClassPathTestCase.java
delete mode 100644 src/test/java/org/jboss/logging/Log4j2ProviderTestCase.java
delete mode 100644 src/test/java/org/jboss/logging/Log4jClassPathTestCase.java
delete mode 100644 src/test/java/org/jboss/logging/Log4jProviderTestCase.java
diff --git a/pom.xml b/pom.xml
index 60a9de3..88af23f 100644
index d4d287c..74fc114 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,8 +31,6 @@
<properties>
@@ -56,8 +56,6 @@
<!-- Dependency versions -->
- <version.org.apache.log4j>1.2.16</version.org.apache.log4j>
- <version.org.apache.logging.log4j>2.11.2</version.org.apache.logging.log4j>
<version.org.jboss.logmanager>2.1.9.Final</version.org.jboss.logmanager>
<version.org.sfl4j>1.7.25</version.org.sfl4j>
</properties>
@@ -44,28 +42,6 @@
<version.ch.qos.logback>1.4.7</version.ch.qos.logback>
<version.module-info>1.2</version.module-info>
- <version.org.apache.log4j>1.2.17</version.org.apache.log4j>
- <version.org.apache.logging.log4j>2.20.0</version.org.apache.logging.log4j>
<version.org.jboss.logmanager>2.1.19.Final</version.org.jboss.logmanager>
<version.org.junit>5.9.3</version.org.junit>
<version.org.sfl4j>2.0.7</version.org.sfl4j>
@@ -88,28 +86,6 @@
<version>${version.org.jboss.logmanager}</version>
<scope>provided</scope>
</dependency>
@ -58,7 +66,20 @@ index 60a9de3..88af23f 100644
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -109,7 +85,6 @@
@@ -129,12 +105,6 @@
<version>${version.ch.qos.logback}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <version>${version.org.apache.logging.log4j}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
@@ -353,7 +323,6 @@
${project.groupId}.*;version=${project.version};-split-package:=error
</Export-Package>
<Import-Package>
@ -68,20 +89,20 @@ index 60a9de3..88af23f 100644
</instructions>
diff --git a/src/main/java/org/jboss/logging/Log4j2Logger.java b/src/main/java/org/jboss/logging/Log4j2Logger.java
deleted file mode 100644
index 3603499..0000000
index 4dc2fed..0000000
--- a/src/main/java/org/jboss/logging/Log4j2Logger.java
+++ /dev/null
@@ -1,92 +0,0 @@
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2013 Red Hat, Inc.
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
@ -109,9 +130,10 @@ index 3603499..0000000
- super(name);
- org.apache.logging.log4j.Logger logger = LogManager.getLogger(name);
- if (!(logger instanceof AbstractLogger)) {
- throw new LoggingException("The logger for [" + name + "] does not extend AbstractLogger. Actual logger: " + logger.getClass().getName());
- throw new LoggingException("The logger for [" + name + "] does not extend AbstractLogger. Actual logger: "
- + logger.getClass().getName());
- }
- this.logger = (AbstractLogger)logger;
- this.logger = (AbstractLogger) logger;
- this.messageFactory = new MessageFormatMessageFactory();
- }
-
@ -121,24 +143,30 @@ index 3603499..0000000
- }
-
- @Override
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters,
- final Throwable thrown) {
- final org.apache.logging.log4j.Level translatedLevel = Log4j2Logger.translate(level);
- if (this.logger.isEnabled(translatedLevel)) {
- try {
- this.logger.logMessage(loggerClassName, translatedLevel, null,
- (parameters == null || parameters.length == 0) ? this.messageFactory.newMessage(message) : this.messageFactory.newMessage(String.valueOf(message), parameters),
- (parameters == null || parameters.length == 0) ? this.messageFactory.newMessage(String.valueOf(message))
- : this.messageFactory.newMessage(String.valueOf(message), parameters),
- thrown);
- } catch (Throwable ignored) { }
- } catch (Throwable ignored) {
- }
- }
- }
-
- @Override
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) {
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters,
- final Throwable thrown) {
- final org.apache.logging.log4j.Level translatedLevel = Log4j2Logger.translate(level);
- if (this.logger.isEnabled(translatedLevel)) {
- try {
- this.logger.logMessage(loggerClassName, translatedLevel, null, new StringFormattedMessage(format, parameters), thrown);
- } catch (Throwable ignored) { }
- this.logger.logMessage(loggerClassName, translatedLevel, null, new StringFormattedMessage(format, parameters),
- thrown);
- } catch (Throwable ignored) {
- }
- }
- }
-
@ -166,20 +194,20 @@ index 3603499..0000000
-}
diff --git a/src/main/java/org/jboss/logging/Log4j2LoggerProvider.java b/src/main/java/org/jboss/logging/Log4j2LoggerProvider.java
deleted file mode 100644
index 84417d2..0000000
index b9109be..0000000
--- a/src/main/java/org/jboss/logging/Log4j2LoggerProvider.java
+++ /dev/null
@@ -1,96 +0,0 @@
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2013 Red Hat, Inc.
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
@ -195,7 +223,13 @@ index 84417d2..0000000
-
-import org.apache.logging.log4j.ThreadContext;
-
-final class Log4j2LoggerProvider implements LoggerProvider {
-/**
- * An implementation of the {@linkplain LoggerProvider log provider} for Log4j 2.
- * <p>
- * This binds to the Log4j 2 API and does not require a specific implementation of the Log4j 2 API.
- * </p>
- */
-public final class Log4j2LoggerProvider implements LoggerProvider {
-
- @Override
- public Log4j2Logger getLogger(String name) {
@ -228,7 +262,7 @@ index 84417d2..0000000
-
- @Override
- public Map<String, Object> getMdcMap() {
- return new HashMap<String, Object>(ThreadContext.getImmutableContext());
- return new HashMap<>(ThreadContext.getImmutableContext());
- }
-
- @Override
@ -268,20 +302,20 @@ index 84417d2..0000000
-}
diff --git a/src/main/java/org/jboss/logging/Log4jLogger.java b/src/main/java/org/jboss/logging/Log4jLogger.java
deleted file mode 100644
index 3f7a3f2..0000000
index 8d9128d..0000000
--- a/src/main/java/org/jboss/logging/Log4jLogger.java
+++ /dev/null
@@ -1,74 +0,0 @@
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2010 Red Hat, Inc.
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
@ -310,18 +344,26 @@ index 3f7a3f2..0000000
- return logger.isEnabledFor(l) && l.isGreaterOrEqual(logger.getEffectiveLevel());
- }
-
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters,
- final Throwable thrown) {
- final org.apache.log4j.Level translatedLevel = translate(level);
- if (logger.isEnabledFor(translatedLevel)) try {
- logger.log(loggerClassName, translatedLevel, parameters == null || parameters.length == 0 ? message : MessageFormat.format(String.valueOf(message), parameters), thrown);
- } catch (Throwable ignored) {}
- if (logger.isEnabledFor(translatedLevel))
- try {
- logger.log(loggerClassName, translatedLevel, parameters == null || parameters.length == 0 ? message
- : MessageFormat.format(String.valueOf(message), parameters), thrown);
- } catch (Throwable ignored) {
- }
- }
-
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) {
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters,
- final Throwable thrown) {
- final org.apache.log4j.Level translatedLevel = translate(level);
- if (logger.isEnabledFor(translatedLevel)) try {
- logger.log(loggerClassName, translatedLevel, parameters == null ? String.format(format) : String.format(format, parameters), thrown);
- } catch (Throwable ignored) {}
- if (logger.isEnabledFor(translatedLevel))
- try {
- logger.log(loggerClassName, translatedLevel,
- parameters == null ? String.format(format) : String.format(format, parameters), thrown);
- } catch (Throwable ignored) {
- }
- }
-
- private static org.apache.log4j.Level translate(final Level level) {
@ -348,20 +390,20 @@ index 3f7a3f2..0000000
-}
diff --git a/src/main/java/org/jboss/logging/Log4jLoggerProvider.java b/src/main/java/org/jboss/logging/Log4jLoggerProvider.java
deleted file mode 100644
index 69bdd5f..0000000
index 9bb0c74..0000000
--- a/src/main/java/org/jboss/logging/Log4jLoggerProvider.java
+++ /dev/null
@@ -1,86 +0,0 @@
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2010 Red Hat, Inc.
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
@ -378,26 +420,37 @@ index 69bdd5f..0000000
-import org.apache.log4j.MDC;
-import org.apache.log4j.NDC;
-
-final class Log4jLoggerProvider implements LoggerProvider {
-/**
- * An implementation of the {@linkplain LoggerProvider log provider} for log4j.
- * <p>
- * Please note that log4j reached end of life on August 5, 2015. Prefer using a log manager and provider.
- * </p>
- */
-public final class Log4jLoggerProvider implements LoggerProvider {
-
- @Override
- public Logger getLogger(final String name) {
- return new Log4jLogger("".equals(name) ? "ROOT" : name);
- }
-
- @Override
- public void clearMdc() {
- MDC.clear();
- }
-
- @Override
- public Object getMdc(String key) {
- return MDC.get(key);
- }
-
- @Override
- public Map<String, Object> getMdcMap() {
- @SuppressWarnings("unchecked")
- final Map<String, Object> map = MDC.getContext();
- return map == null ? Collections.<String, Object>emptyMap() : map;
- return map == null ? Collections.emptyMap() : map;
- }
-
- @Override
- public Object putMdc(String key, Object val) {
- try {
- return MDC.get(key);
@ -406,40 +459,48 @@ index 69bdd5f..0000000
- }
- }
-
- @Override
- public void removeMdc(String key) {
- MDC.remove(key);
- }
-
- @Override
- public void clearNdc() {
- NDC.remove();
- }
-
- @Override
- public String getNdc() {
- return NDC.get();
- }
-
- @Override
- public int getNdcDepth() {
- return NDC.getDepth();
- }
-
- @Override
- public String peekNdc() {
- return NDC.peek();
- }
-
- @Override
- public String popNdc() {
- return NDC.pop();
- }
-
- @Override
- public void pushNdc(String message) {
- NDC.push(message);
- }
-
- @Override
- public void setNdcMaxDepth(int maxDepth) {
- NDC.setMaxDepth(maxDepth);
- }
-}
diff --git a/src/main/java/org/jboss/logging/LoggerProviders.java b/src/main/java/org/jboss/logging/LoggerProviders.java
index 0608283..8e393d1 100644
index 1ace1e8..8a0ab5e 100644
--- a/src/main/java/org/jboss/logging/LoggerProviders.java
+++ b/src/main/java/org/jboss/logging/LoggerProviders.java
@@ -45,10 +45,6 @@ final class LoggerProviders {
@ -453,25 +514,32 @@ index 0608283..8e393d1 100644
} else if ("slf4j".equalsIgnoreCase(loggerProvider)) {
return trySlf4j("system property");
}
@@ -80,17 +76,6 @@ final class LoggerProviders {
@@ -81,11 +77,6 @@ final class LoggerProviders {
} catch (Throwable t) {
// nope...
}
- try {
- // MUST try Log4j 2.x BEFORE Log4j 1.x because Log4j 2.x also passes Log4j 1.x test in some circumstances
- return tryLog4j2(cl, null);
- } catch (Throwable t) {
- // nope...
- }
- try {
- return tryLog4j(cl, null);
- } catch (Throwable t) {
- // nope...
- }
try {
// only use slf4j if Logback is in use
Class.forName("ch.qos.logback.classic.Logger", false, cl);
@@ -113,27 +98,6 @@ final class LoggerProviders {
@@ -93,12 +84,6 @@ final class LoggerProviders {
} catch (Throwable t) {
// nope...
}
- try {
- // log4j has been EOL'd since 2015. It should be checked last.
- return tryLog4j(cl, null);
- } catch (Throwable t) {
- // nope...
- }
return tryJDK(null);
}
@@ -114,27 +99,6 @@ final class LoggerProviders {
return provider;
}
@ -499,6 +567,382 @@ index 0608283..8e393d1 100644
private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException {
final Class<? extends LogManager> logManagerClass = LogManager.getLogManager().getClass();
if (logManagerClass == Class.forName("org.jboss.logmanager.LogManager", false, cl)
diff --git a/src/test/java/org/jboss/logging/Log4j2ClassPathTestCase.java b/src/test/java/org/jboss/logging/Log4j2ClassPathTestCase.java
deleted file mode 100644
index 88f05f4..0000000
--- a/src/test/java/org/jboss/logging/Log4j2ClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4j2ClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4j2Logger.class;
- }
-}
diff --git a/src/test/java/org/jboss/logging/Log4j2ProviderTestCase.java b/src/test/java/org/jboss/logging/Log4j2ProviderTestCase.java
deleted file mode 100644
index 63aa43c..0000000
--- a/src/test/java/org/jboss/logging/Log4j2ProviderTestCase.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.io.Serializable;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.AbstractAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4j2ProviderTestCase extends AbstractLoggerTestCase {
- private TestAppender appender;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "log4j2");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- final Configuration config = ctx.getConfiguration();
- appender = (TestAppender) config.getAppenders().get("TestAppender");
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", ThreadContext.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- // TODO (jrp) This is a weird case we should validate. NDC.get() does ThreadContext.peek() which doesn't seem
- // TODO (jrp) correct. The method should likely do ThreadContext.getImmutableStack().toString(). At least that
- // TODO (jrp) is what the NdcPatternConverter does.
- //Assertions.assertEquals("[value1, value2]", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Test the log manager values
- Assertions.assertEquals("[value1, value2]", ThreadContext.getImmutableStack().toString());
- Assertions.assertEquals(2, ThreadContext.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- Assertions.assertEquals("value1", ThreadContext.peek());
- Assertions.assertEquals(1, ThreadContext.getDepth());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LogEvent event = appender.queue.poll();
- Assertions.assertNotNull(event, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), event.getLevel().toString());
- Assertions.assertEquals(msg, event.getMessage().getFormattedMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4j2Logger.class;
- }
-
- @SuppressWarnings("unused")
- @Plugin(name = "TestAppender", category = "Core", elementType = "appender", printObject = true)
- public static class TestAppender extends AbstractAppender {
- final BlockingQueue<LogEvent> queue = new LinkedBlockingQueue<>();
-
- protected TestAppender(String name, Filter filter, Layout<? extends Serializable> layout) {
- super(name, filter, layout, false, null);
- }
-
- @Override
- public void append(final LogEvent event) {
- queue.add(event.toImmutable());
- }
-
- @Override
- public void stop() {
- queue.clear();
- super.stop();
- }
-
- @PluginFactory
- public static TestAppender createAppender(@PluginAttribute("name") String name,
- @PluginElement("Layout") Layout<? extends Serializable> layout,
- @PluginElement("Filter") final Filter filter,
- @PluginAttribute("otherAttribute") String otherAttribute) {
- if (name == null) {
- LOGGER.error("No name provided for TestAppender");
- return null;
- }
- if (layout == null) {
- layout = PatternLayout.createDefaultLayout();
- }
- return new TestAppender(name, filter, layout);
- }
- }
-}
diff --git a/src/test/java/org/jboss/logging/Log4jClassPathTestCase.java b/src/test/java/org/jboss/logging/Log4jClassPathTestCase.java
deleted file mode 100644
index 9647fe8..0000000
--- a/src/test/java/org/jboss/logging/Log4jClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4jClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4jLogger.class;
- }
-}
diff --git a/src/test/java/org/jboss/logging/Log4jProviderTestCase.java b/src/test/java/org/jboss/logging/Log4jProviderTestCase.java
deleted file mode 100644
index d101579..0000000
--- a/src/test/java/org/jboss/logging/Log4jProviderTestCase.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Level;
-import org.apache.log4j.spi.LoggingEvent;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Log4jProviderTestCase extends AbstractLoggerTestCase {
- private TestAppender appender;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "log4j");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- appender = createAppender(logger.getName());
- }
-
- @AfterEach
- public void removeAppender() {
- org.apache.log4j.Logger.getLogger(logger.getName()).removeAppender(appender);
- appender.close();
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", org.apache.log4j.MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- Assertions.assertEquals("value1 value2", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Test the log manager values
- Assertions.assertEquals("value1 value2", org.apache.log4j.NDC.get());
- Assertions.assertEquals(2, org.apache.log4j.NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- Assertions.assertEquals("value1", org.apache.log4j.NDC.get());
- Assertions.assertEquals(1, org.apache.log4j.NDC.getDepth());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LoggingEvent event = appender.queue.poll();
- Assertions.assertNotNull(event, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), event.getLevel().toString());
- Assertions.assertEquals(msg, event.getMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Log4jLogger.class;
- }
-
- private static TestAppender createAppender(final String loggerName) {
- final TestAppender appender = new TestAppender();
- final org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(loggerName);
- log4jLogger.addAppender(appender);
- log4jLogger.setLevel(Level.ALL);
- return appender;
- }
-
- private static class TestAppender extends AppenderSkeleton {
- final BlockingQueue<LoggingEvent> queue = new LinkedBlockingQueue<>();
-
- @Override
- protected void append(final LoggingEvent loggingEvent) {
- queue.add(loggingEvent);
- }
-
- @Override
- public void close() throws SecurityException {
- queue.clear();
- }
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
- }
-}
--
2.31.1
2.40.1

View File

@ -0,0 +1,556 @@
From 2053d0851f63bac9d74898c212cc420ed3f94add Mon Sep 17 00:00:00 2001
From: Chris Kelley <ckelley@redhat.com>
Date: Tue, 6 Jun 2023 21:45:57 +0100
Subject: [PATCH 2/3] Drop jboss-logmanager dependency
---
pom.xml | 7 -
.../jboss/logging/JBossLogManagerLogger.java | 81 ---------
.../logging/JBossLogManagerProvider.java | 163 ------------------
.../org/jboss/logging/LoggerProviders.java | 22 +--
.../JBossLogManagerClassPathTestCase.java | 30 ----
.../JBossLogManagerProviderTestCase.java | 158 -----------------
6 files changed, 1 insertion(+), 460 deletions(-)
delete mode 100644 src/main/java/org/jboss/logging/JBossLogManagerLogger.java
delete mode 100644 src/main/java/org/jboss/logging/JBossLogManagerProvider.java
delete mode 100644 src/test/java/org/jboss/logging/JBossLogManagerClassPathTestCase.java
delete mode 100644 src/test/java/org/jboss/logging/JBossLogManagerProviderTestCase.java
diff --git a/pom.xml b/pom.xml
index 74fc114..422a767 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,6 @@
<!-- Dependency versions -->
<version.ch.qos.logback>1.4.7</version.ch.qos.logback>
<version.module-info>1.2</version.module-info>
- <version.org.jboss.logmanager>2.1.19.Final</version.org.jboss.logmanager>
<version.org.junit>5.9.3</version.org.junit>
<version.org.sfl4j>2.0.7</version.org.sfl4j>
@@ -80,12 +79,6 @@
</dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.jboss.logmanager</groupId>
- <artifactId>jboss-logmanager</artifactId>
- <version>${version.org.jboss.logmanager}</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
diff --git a/src/main/java/org/jboss/logging/JBossLogManagerLogger.java b/src/main/java/org/jboss/logging/JBossLogManagerLogger.java
deleted file mode 100644
index bd4c9a0..0000000
--- a/src/main/java/org/jboss/logging/JBossLogManagerLogger.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import org.jboss.logmanager.ExtLogRecord;
-
-final class JBossLogManagerLogger extends Logger {
-
- private static final long serialVersionUID = 7429618317727584742L;
-
- private final org.jboss.logmanager.Logger logger;
-
- JBossLogManagerLogger(final String name, final org.jboss.logmanager.Logger logger) {
- super(name);
- this.logger = logger;
- }
-
- public boolean isEnabled(final Level level) {
- return logger.isLoggable(translate(level));
- }
-
- protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters,
- final Throwable thrown) {
- java.util.logging.Level translatedLevel = translate(level);
- if (logger.isLoggable(translatedLevel)) {
- if (parameters == null) {
- logger.log(loggerClassName, translatedLevel, String.valueOf(message), thrown);
- } else {
- logger.log(loggerClassName, translatedLevel, String.valueOf(message), ExtLogRecord.FormatStyle.MESSAGE_FORMAT,
- parameters, thrown);
- }
- }
- }
-
- protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters,
- final Throwable thrown) {
- if (parameters == null) {
- logger.log(loggerClassName, translate(level), format, thrown);
- } else {
- logger.log(loggerClassName, translate(level), format, ExtLogRecord.FormatStyle.PRINTF, parameters, thrown);
- }
- }
-
- private static java.util.logging.Level translate(final Level level) {
- if (level == Level.TRACE) {
- return org.jboss.logmanager.Level.TRACE;
- } else if (level == Level.DEBUG) {
- return org.jboss.logmanager.Level.DEBUG;
- }
- return infoOrHigher(level);
- }
-
- private static java.util.logging.Level infoOrHigher(final Level level) {
- if (level == Level.INFO) {
- return org.jboss.logmanager.Level.INFO;
- } else if (level == Level.WARN) {
- return org.jboss.logmanager.Level.WARN;
- } else if (level == Level.ERROR) {
- return org.jboss.logmanager.Level.ERROR;
- } else if (level == Level.FATAL) {
- return org.jboss.logmanager.Level.FATAL;
- }
- return org.jboss.logmanager.Level.ALL;
- }
-}
diff --git a/src/main/java/org/jboss/logging/JBossLogManagerProvider.java b/src/main/java/org/jboss/logging/JBossLogManagerProvider.java
deleted file mode 100644
index bdeac67..0000000
--- a/src/main/java/org/jboss/logging/JBossLogManagerProvider.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import static org.jboss.logmanager.Logger.AttachmentKey;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.jboss.logmanager.LogContext;
-import org.jboss.logmanager.MDC;
-import org.jboss.logmanager.NDC;
-
-/**
- * An implementation of the {@linkplain LoggerProvider log provider} for the JBoss Log Manager.
- */
-public final class JBossLogManagerProvider implements LoggerProvider {
-
- private static final AttachmentKey<Logger> KEY = new AttachmentKey<>();
- private static final AttachmentKey<ConcurrentMap<String, Logger>> LEGACY_KEY = new AttachmentKey<>();
-
- @Override
- public Logger getLogger(final String name) {
- final SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- return AccessController.doPrivileged((PrivilegedAction<Logger>) () -> {
- try {
- return doGetLogger(name);
- } catch (NoSuchMethodError ignore) {
- }
- // fallback
- return doLegacyGetLogger(name);
- });
- } else {
- try {
- return doGetLogger(name);
- } catch (NoSuchMethodError ignore) {
- }
- // fallback
- return doLegacyGetLogger(name);
- }
- }
-
- private static Logger doLegacyGetLogger(final String name) {
- final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger("");
- ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY);
- if (loggers == null) {
- loggers = new ConcurrentHashMap<>();
- final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers);
- if (appearing != null) {
- loggers = appearing;
- }
- }
-
- Logger l = loggers.get(name);
- if (l != null) {
- return l;
- }
-
- final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name);
- l = new JBossLogManagerLogger(name, logger);
- final Logger appearing = loggers.putIfAbsent(name, l);
- if (appearing == null) {
- return l;
- }
- return appearing;
- }
-
- private static Logger doGetLogger(final String name) {
- Logger l = LogContext.getLogContext().getAttachment(name, KEY);
- if (l != null) {
- return l;
- }
- final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name);
- l = new JBossLogManagerLogger(name, logger);
- Logger a = logger.attachIfAbsent(KEY, l);
- if (a == null) {
- return l;
- } else {
- return a;
- }
- }
-
- @Override
- public void clearMdc() {
- MDC.clear();
- }
-
- @Override
- public Object putMdc(final String key, final Object value) {
- return MDC.putObject(key, value);
- }
-
- @Override
- public Object getMdc(final String key) {
- return MDC.getObject(key);
- }
-
- @Override
- public void removeMdc(final String key) {
- MDC.removeObject(key);
- }
-
- @Override
- public Map<String, Object> getMdcMap() {
- // we can re-define the erasure of this map because MDC does not make further use of the copy
- return MDC.copyObject();
- }
-
- @Override
- public void clearNdc() {
- NDC.clear();
- }
-
- @Override
- public String getNdc() {
- return NDC.get();
- }
-
- @Override
- public int getNdcDepth() {
- return NDC.getDepth();
- }
-
- @Override
- public String popNdc() {
- return NDC.pop();
- }
-
- @Override
- public String peekNdc() {
- return NDC.get();
- }
-
- @Override
- public void pushNdc(final String message) {
- NDC.push(message);
- }
-
- @Override
- public void setNdcMaxDepth(final int maxDepth) {
- NDC.trimTo(maxDepth);
- }
-}
diff --git a/src/main/java/org/jboss/logging/LoggerProviders.java b/src/main/java/org/jboss/logging/LoggerProviders.java
index 8a0ab5e..0154aea 100644
--- a/src/main/java/org/jboss/logging/LoggerProviders.java
+++ b/src/main/java/org/jboss/logging/LoggerProviders.java
@@ -21,7 +21,6 @@ package org.jboss.logging;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
-import java.util.logging.LogManager;
final class LoggerProviders {
static final String LOGGING_PROVIDER_KEY = "org.jboss.logging.provider";
@@ -41,9 +40,7 @@ final class LoggerProviders {
// Check the system property
final String loggerProvider = SecurityActions.getSystemProperty(LOGGING_PROVIDER_KEY);
if (loggerProvider != null) {
- if ("jboss".equalsIgnoreCase(loggerProvider)) {
- return tryJBossLogManager(cl, "system property");
- } else if ("jdk".equalsIgnoreCase(loggerProvider)) {
+ if ("jdk".equalsIgnoreCase(loggerProvider)) {
return tryJDK("system property");
} else if ("slf4j".equalsIgnoreCase(loggerProvider)) {
return trySlf4j("system property");
@@ -72,11 +69,6 @@ final class LoggerProviders {
}
// Finally search the class path
- try {
- return tryJBossLogManager(cl, null);
- } catch (Throwable t) {
- // nope...
- }
try {
// only use slf4j if Logback is in use
Class.forName("ch.qos.logback.classic.Logger", false, cl);
@@ -99,18 +91,6 @@ final class LoggerProviders {
return provider;
}
- private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException {
- final Class<? extends LogManager> logManagerClass = LogManager.getLogManager().getClass();
- if (logManagerClass == Class.forName("org.jboss.logmanager.LogManager", false, cl)
- && Class.forName("org.jboss.logmanager.Logger$AttachmentKey", true, cl).getClassLoader() == logManagerClass
- .getClassLoader()) {
- final LoggerProvider provider = new JBossLogManagerProvider();
- logProvider(provider, via);
- return provider;
- }
- throw new IllegalStateException();
- }
-
private static void logProvider(final LoggerProvider provider, final String via) {
// Log a debug message indicating which logger we are using
final Logger logger = provider.getLogger("org.jboss.logging");
diff --git a/src/test/java/org/jboss/logging/JBossLogManagerClassPathTestCase.java b/src/test/java/org/jboss/logging/JBossLogManagerClassPathTestCase.java
deleted file mode 100644
index f574187..0000000
--- a/src/test/java/org/jboss/logging/JBossLogManagerClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class JBossLogManagerClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return JBossLogManagerLogger.class;
- }
-}
diff --git a/src/test/java/org/jboss/logging/JBossLogManagerProviderTestCase.java b/src/test/java/org/jboss/logging/JBossLogManagerProviderTestCase.java
deleted file mode 100644
index d96ddc3..0000000
--- a/src/test/java/org/jboss/logging/JBossLogManagerProviderTestCase.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import org.jboss.logmanager.LogContext;
-import org.jboss.logmanager.LogContextSelector;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class JBossLogManagerProviderTestCase extends AbstractLoggerTestCase {
- private static final LogContextSelector DEFAULT_SELECTOR = LogContext.getLogContextSelector();
- private static final AtomicBoolean SET_LOG_MANAGER = new AtomicBoolean(true);
-
- private LogContext logContext;
- private TestHandler handler;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- SET_LOG_MANAGER.set(System.getProperty("java.util.logging.manager") == null);
- if (SET_LOG_MANAGER.get()) {
- System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
- }
- System.setProperty("org.jboss.logging.provider", "jboss");
- }
-
- @AfterAll
- public static void tearDown() {
- if (SET_LOG_MANAGER.get()) {
- System.clearProperty("java.util.logging.manager");
- }
- }
-
- @BeforeEach
- public void setupLogContext() {
- logContext = LogContext.create();
- LogContext.setLogContextSelector(() -> logContext);
- logger = Logger.getLogger(getClass());
- handler = createHandler(logContext, logger.getName());
- }
-
- @AfterEach
- public void closeLogContext() throws Exception {
- logContext.close();
- LogContext.setLogContextSelector(DEFAULT_SELECTOR);
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", org.jboss.logmanager.MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- final String expectedValue = "value1.value2";
- Assertions.assertEquals(expectedValue, NDC.peek());
- Assertions.assertEquals(expectedValue, NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Test the log manager values
- Assertions.assertEquals(expectedValue, org.jboss.logmanager.NDC.get());
- Assertions.assertEquals(2, org.jboss.logmanager.NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- Assertions.assertEquals("value1", org.jboss.logmanager.NDC.get());
- Assertions.assertEquals(1, org.jboss.logmanager.NDC.getDepth());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final LogRecord logRecord = handler.queue.poll();
- Assertions.assertNotNull(logRecord, String.format("No record found for %s", level));
- Assertions.assertEquals(level.name(), logRecord.getLevel().getName());
- Assertions.assertEquals(msg, logRecord.getMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return JBossLogManagerLogger.class;
- }
-
- private static TestHandler createHandler(final LogContext logContext, final String loggerName) {
- final TestHandler handler = new TestHandler();
- final java.util.logging.Logger julLogger = logContext.getLogger(loggerName);
- julLogger.addHandler(handler);
- julLogger.setLevel(Level.ALL);
- return handler;
- }
-
- private static class TestHandler extends Handler {
- final BlockingQueue<LogRecord> queue = new LinkedBlockingQueue<>();
-
- @Override
- public void publish(final LogRecord record) {
- queue.add(record);
- }
-
- @Override
- public void flush() {
- }
-
- @Override
- public void close() throws SecurityException {
- queue.clear();
- }
- }
-}
--
2.40.1

View File

@ -0,0 +1,189 @@
From 260e98e9268fa0aff117dbfaa0ba030994f3f54b Mon Sep 17 00:00:00 2001
From: Chris Kelley <ckelley@redhat.com>
Date: Wed, 14 Jun 2023 11:12:00 +0100
Subject: [PATCH 3/3] Drop *TestCase that depend on retired package
The ch.qos.logback* packages are no longer packaged in Fedora so we need
to remove this test.
---
.../jboss/logging/Slf4jClassPathTestCase.java | 30 ----
.../jboss/logging/Slf4jProviderTestCase.java | 130 ------------------
2 files changed, 160 deletions(-)
delete mode 100644 src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
delete mode 100644 src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
diff --git a/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java b/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
deleted file mode 100644
index acc1df1..0000000
--- a/src/test/java/org/jboss/logging/Slf4jClassPathTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Slf4jClassPathTestCase extends AbstractClassPathTestCase {
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Slf4jLocationAwareLogger.class;
- }
-}
diff --git a/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java b/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
deleted file mode 100644
index 7e07033..0000000
--- a/src/test/java/org/jboss/logging/Slf4jProviderTestCase.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * Copyright 2023 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.logging;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.AppenderBase;
-
-/**
- * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
- */
-public class Slf4jProviderTestCase extends AbstractLoggerTestCase {
- private TestAppender appender;
- private Logger logger;
-
- @BeforeAll
- public static void setup() {
- System.setProperty("org.jboss.logging.provider", "slf4j");
- }
-
- @BeforeEach
- public void setupLogContext() {
- logger = Logger.getLogger(getClass());
- appender = createHandler(logger.getName());
- }
-
- @AfterEach
- public void removeAppender() {
- ch.qos.logback.classic.Logger lbLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logger.getName());
- lbLogger.detachAppender(appender);
- appender.stop();
- }
-
- @Test
- public void testMdc() {
- MDC.put("test.key", "value");
- Assertions.assertEquals("value", MDC.get("test.key"));
- Assertions.assertEquals("value", org.slf4j.MDC.get("test.key"));
- }
-
- @Test
- public void testNdc() {
- NDC.push("value1");
- NDC.push("value2");
- Assertions.assertEquals("value2", NDC.peek());
- Assertions.assertEquals("value1 value2", NDC.get());
- Assertions.assertEquals(2, NDC.getDepth());
-
- // Pop the stack
- Assertions.assertEquals("value2", NDC.pop());
- Assertions.assertEquals(1, NDC.getDepth());
- Assertions.assertEquals("value1", NDC.get());
- }
-
- @Override
- void testLog(final Logger.Level level) {
- final String msg = String.format("Test log message at %s", level);
- logger.log(level, msg);
-
- Assertions.assertTrue(logger.isEnabled(level), String.format("Logger not enabled for level %s", level));
- testLog(msg, level);
- }
-
- @Override
- void testLog(final String msg, final Logger.Level level) {
- final ILoggingEvent event = appender.queue.poll();
- Assertions.assertNotNull(event, String.format("No record found for %s", level));
- final Logger.Level translatedLevel = level == Logger.Level.FATAL ? Logger.Level.ERROR : level;
- Assertions.assertEquals(translatedLevel.name(), event.getLevel().toString());
- Assertions.assertEquals(msg, event.getFormattedMessage());
- }
-
- @Override
- Logger getLogger() {
- return logger;
- }
-
- @Override
- Class<? extends Logger> getLoggerClass() {
- return Slf4jLocationAwareLogger.class;
- }
-
- private static TestAppender createHandler(final String loggerName) {
- final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- final TestAppender appender = new TestAppender();
- appender.setContext(context);
- appender.start();
-
- ch.qos.logback.classic.Logger lbLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(loggerName);
- lbLogger.addAppender(appender);
- lbLogger.setLevel(Level.ALL);
- return appender;
- }
-
- public static class TestAppender extends AppenderBase<ILoggingEvent> {
- final BlockingQueue<ILoggingEvent> queue = new LinkedBlockingQueue<>();
-
- @Override
- protected void append(final ILoggingEvent event) {
- queue.add(event);
- }
- }
-}
--
2.40.1

View File

@ -2,22 +2,24 @@
%global namedversion %{version}%{?namedreltag}
Name: jboss-logging
Version: 3.4.1
Release: 14%{?dist}
Version: 3.5.1
Release: 1%{?dist}
Summary: The JBoss Logging Framework
License: Apache-2.0
URL: https://github.com/jboss-logging/jboss-logging
Source0: %{url}/archive/%{namedversion}/%{name}-%{namedversion}.tar.gz
Patch1: 0001-Drop-log4j-dependency.patch
Patch2: 0001-Drop-jboss-logmanager-dependency.patch
Patch2: 0002-Drop-jboss-logmanager-dependency.patch
Patch3: 0003-Drop-TestCase-that-depend-on-retired-package.patch
BuildArch: noarch
ExclusiveArch: %{java_arches} noarch
ExclusiveArch: %{java_arches} noarch
BuildRequires: maven-local
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.jboss:jboss-parent:pom:)
BuildRequires: mvn(org.junit:junit-bom:pom:)
BuildRequires: mvn(org.apache.logging:logging-parent:pom:)
BuildRequires: mvn(org.slf4j:slf4j-api)
%description
@ -26,11 +28,12 @@ This package contains the JBoss Logging Framework.
%prep
%autosetup -n %{name}-%{namedversion} -p 1
# Unneeded task
# Unneeded tasks
%pom_remove_dep ch.qos.logback:logback-classic
%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin io.github.dmlloyd.module-info:module-info
cp -p src/main/resources/META-INF/LICENSE.txt .
sed -i 's/\r//' LICENSE.txt
%pom_set_parent org.apache.logging:logging-parent
%build
%mvn_build -j
@ -42,6 +45,9 @@ sed -i 's/\r//' LICENSE.txt
%license LICENSE.txt
%changelog
* Tue Jun 06 2023 Chris Kelley <ckelley@redhat.com> - 3.5.1-1
- Rebase to version 3.5.1.Final
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild