jboss-logging package is retired on branch c10s for CS-2364

This commit is contained in:
David Fan 2024-07-23 09:29:20 +00:00
parent 23ffe35b8c
commit 570cf54589
8 changed files with 1 additions and 1929 deletions

14
.gitignore vendored
View File

@ -1,14 +0,0 @@
/results_*
/*.src.rpm
/jboss-logging-3.0.1.GA.tar.xz
/jboss-logging-3.1.0.CR1.tar.xz
/jboss-logging-3.1.0.GA.tar.xz
/jboss-logging-3.1.2.GA.tar.xz
/3.1.3.GA.tar.gz
/3.1.4.GA.tar.gz
/3.3.0.Final.tar.gz
/jboss-logging-3.4.1.Final.tar.gz
/jboss-logging-3.5.1.Final.tar.gz
/jboss-logging-3.5.2.Final.tar.gz
/jboss-logging-3.5.3.Final.tar.gz

View File

@ -1,17 +0,0 @@
---
downstream_package_name: jboss-logging
specfile_path: jboss-logging.spec
upstream_package_name: jboss-logging
upstream_project_url: https://github.com/jboss-logging/jboss-logging
upstream_tag_template: "{version}.Final"
actions:
post-upstream-clone:
- "wget https://src.fedoraproject.org/rpms/jboss-logging/raw/main/f/jboss-logging.spec -O jboss-logging.spec"
jobs:
- job: pull_from_upstream
trigger: release
dist_git_branches:
- fedora-development

View File

@ -1,948 +0,0 @@
From 1320fd0d2ace4d71f22142869c1b1e659ae4a567 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 | 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 cb54082..2b92751 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,8 +56,6 @@
<!-- Dependency versions -->
<version.ch.qos.logback>1.4.8</version.ch.qos.logback>
<version.module-info>2.1</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>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${version.org.apache.log4j}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>com.sun.jdmk</groupId>
- <artifactId>jmxtools</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.jmx</groupId>
- <artifactId>jmxri</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <version>${version.org.apache.logging.log4j}</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -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>
- org.apache.log4j.config;resolution:=optional,
*;resolution:=optional
</Import-Package>
</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 4dc2fed..0000000
--- a/src/main/java/org/jboss/logging/Log4j2Logger.java
+++ /dev/null
@@ -1,99 +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.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.message.MessageFormatMessageFactory;
-import org.apache.logging.log4j.message.StringFormattedMessage;
-import org.apache.logging.log4j.spi.AbstractLogger;
-
-final class Log4j2Logger extends Logger {
-
- private static final long serialVersionUID = -2507841068232627725L;
-
- private final AbstractLogger logger;
- private final MessageFormatMessageFactory messageFactory;
-
- Log4j2Logger(final String name) {
- 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());
- }
- this.logger = (AbstractLogger) logger;
- this.messageFactory = new MessageFormatMessageFactory();
- }
-
- @Override
- public boolean isEnabled(final Level level) {
- return this.logger.isEnabled(Log4j2Logger.translate(level));
- }
-
- @Override
- 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(String.valueOf(message))
- : this.messageFactory.newMessage(String.valueOf(message), parameters),
- thrown);
- } catch (Throwable ignored) {
- }
- }
- }
-
- @Override
- 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) {
- }
- }
- }
-
- private static org.apache.logging.log4j.Level translate(final Level level) {
- if (level == Level.TRACE) {
- return org.apache.logging.log4j.Level.TRACE;
- } else if (level == Level.DEBUG) {
- return org.apache.logging.log4j.Level.DEBUG;
- }
- return infoOrHigher(level);
- }
-
- private static org.apache.logging.log4j.Level infoOrHigher(final Level level) {
- if (level == Level.INFO) {
- return org.apache.logging.log4j.Level.INFO;
- } else if (level == Level.WARN) {
- return org.apache.logging.log4j.Level.WARN;
- } else if (level == Level.ERROR) {
- return org.apache.logging.log4j.Level.ERROR;
- } else if (level == Level.FATAL) {
- return org.apache.logging.log4j.Level.FATAL;
- }
- return org.apache.logging.log4j.Level.ALL;
- }
-}
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 b9109be..0000000
--- a/src/main/java/org/jboss/logging/Log4j2LoggerProvider.java
+++ /dev/null
@@ -1,102 +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.HashMap;
-import java.util.Map;
-
-import org.apache.logging.log4j.ThreadContext;
-
-/**
- * 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) {
- return new Log4j2Logger(name);
- }
-
- @Override
- public void clearMdc() {
- ThreadContext.clearMap();
- }
-
- @Override
- public Object putMdc(String key, Object value) {
- try {
- return ThreadContext.get(key);
- } finally {
- ThreadContext.put(key, String.valueOf(value));
- }
- }
-
- @Override
- public Object getMdc(String key) {
- return ThreadContext.get(key);
- }
-
- @Override
- public void removeMdc(String key) {
- ThreadContext.remove(key);
- }
-
- @Override
- public Map<String, Object> getMdcMap() {
- return new HashMap<>(ThreadContext.getImmutableContext());
- }
-
- @Override
- public void clearNdc() {
- ThreadContext.clearStack();
- }
-
- @Override
- public String getNdc() {
- return ThreadContext.peek();
- }
-
- @Override
- public int getNdcDepth() {
- return ThreadContext.getDepth();
- }
-
- @Override
- public String popNdc() {
- return ThreadContext.pop();
- }
-
- @Override
- public String peekNdc() {
- return ThreadContext.peek();
- }
-
- @Override
- public void pushNdc(String message) {
- ThreadContext.push(message);
- }
-
- @Override
- public void setNdcMaxDepth(int maxDepth) {
- ThreadContext.trim(maxDepth);
- }
-}
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 8d9128d..0000000
--- a/src/main/java/org/jboss/logging/Log4jLogger.java
+++ /dev/null
@@ -1,82 +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.text.MessageFormat;
-
-final class Log4jLogger extends Logger {
-
- private static final long serialVersionUID = -5446154366955151335L;
-
- private final org.apache.log4j.Logger logger;
-
- Log4jLogger(final String name) {
- super(name);
- logger = org.apache.log4j.Logger.getLogger(name);
- }
-
- public boolean isEnabled(final Level level) {
- final org.apache.log4j.Level l = translate(level);
- 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) {
- 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) {
- }
- }
-
- 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) {
- }
- }
-
- private static org.apache.log4j.Level translate(final Level level) {
- if (level == Level.TRACE) {
- return org.apache.log4j.Level.TRACE;
- } else if (level == Level.DEBUG) {
- return org.apache.log4j.Level.DEBUG;
- }
- return infoOrHigher(level);
- }
-
- private static org.apache.log4j.Level infoOrHigher(final Level level) {
- if (level == Level.INFO) {
- return org.apache.log4j.Level.INFO;
- } else if (level == Level.WARN) {
- return org.apache.log4j.Level.WARN;
- } else if (level == Level.ERROR) {
- return org.apache.log4j.Level.ERROR;
- } else if (level == Level.FATAL) {
- return org.apache.log4j.Level.FATAL;
- }
- return org.apache.log4j.Level.ALL;
- }
-}
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 9bb0c74..0000000
--- a/src/main/java/org/jboss/logging/Log4jLoggerProvider.java
+++ /dev/null
@@ -1,105 +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.Collections;
-import java.util.Map;
-
-import org.apache.log4j.MDC;
-import org.apache.log4j.NDC;
-
-/**
- * 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.emptyMap() : map;
- }
-
- @Override
- public Object putMdc(String key, Object val) {
- try {
- return MDC.get(key);
- } finally {
- MDC.put(key, val);
- }
- }
-
- @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 08c16ce..584fa79 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 {
return tryJBossLogManager(cl, "system property");
} else if ("jdk".equalsIgnoreCase(loggerProvider)) {
return tryJDK("system property");
- } else if ("log4j2".equalsIgnoreCase(loggerProvider)) {
- return tryLog4j2(cl, "system property");
- } else if ("log4j".equalsIgnoreCase(loggerProvider)) {
- return tryLog4j(cl, "system property");
} else if ("slf4j".equalsIgnoreCase(loggerProvider)) {
return trySlf4j("system property");
}
@@ -81,11 +77,6 @@ final class LoggerProviders {
} catch (Throwable t) {
// nope...
}
- try {
- return tryLog4j2(cl, null);
- } catch (Throwable t) {
- // nope...
- }
try {
// only use slf4j if Logback is in use
Class.forName("ch.qos.logback.classic.Logger", false, cl);
@@ -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;
}
- // JBLOGGING-95 - Add support for Log4j 2.x
- private static LoggerProvider tryLog4j2(final ClassLoader cl, final String via) throws ClassNotFoundException {
- Class.forName("org.apache.logging.log4j.Logger", true, cl);
- Class.forName("org.apache.logging.log4j.LogManager", true, cl);
- Class.forName("org.apache.logging.log4j.spi.AbstractLogger", true, cl);
- LoggerProvider provider = new Log4j2LoggerProvider();
- // if Log4j 2 has a bad implementation that doesn't extend AbstractLogger, we won't know until getting the first logger throws an exception
- logProvider(provider, via);
- return provider;
- }
-
- private static LoggerProvider tryLog4j(final ClassLoader cl, final String via) throws ClassNotFoundException {
- Class.forName("org.apache.log4j.LogManager", true, cl);
- // JBLOGGING-65 - slf4j can disguise itself as log4j. Test for a class that slf4j doesn't provide.
- // JBLOGGING-94 - JBoss Logging does not detect org.apache.logging.log4j:log4j-1.2-api:2.0
- Class.forName("org.apache.log4j.config.PropertySetter", true, cl);
- final LoggerProvider provider = new Log4jLoggerProvider();
- logProvider(provider, via);
- return provider;
- }
-
private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException {
final Class<? extends LogManager> logManagerClass = LogManager.getLogManager().getClass();
final Class<?> jblLogManager = Class.forName("org.jboss.logmanager.LogManager", false,
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.40.1

View File

@ -1,564 +0,0 @@
From 36962691001339da13d899ac2023e2678c70718e 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 | 30 +---
.../JBossLogManagerClassPathTestCase.java | 30 ----
.../JBossLogManagerProviderTestCase.java | 158 -----------------
6 files changed, 1 insertion(+), 468 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 2b92751..d097a12 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,6 @@
<!-- Dependency versions -->
<version.ch.qos.logback>1.4.8</version.ch.qos.logback>
<version.module-info>2.1</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 584fa79..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,26 +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();
- final Class<?> jblLogManager = Class.forName("org.jboss.logmanager.LogManager", false,
- Logger.class.getClassLoader());
- if (logManagerClass == jblLogManager
- && Class.forName("org.jboss.logmanager.Logger$AttachmentKey", true, cl).getClassLoader() == logManagerClass
- .getClassLoader()) {
- // We do not have an explicit dependency on org.jboss.logmanager as we could end up with cyclic dependencies.
- // Therefore, we check the modules are named, and if they are we add an explicit reads.
- final Module module = LoggerProviders.class.getModule();
- if (module.isNamed()) {
- module.addReads(jblLogManager.getModule());
- }
- 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

@ -1,189 +0,0 @@
From 2be504ac3daf3cb0e46ef57b61fe9b2967fd50e4 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

1
dead.package Normal file
View File

@ -0,0 +1 @@
jboss-logging package is retired on branch c10s for CS-2364

View File

@ -1,196 +0,0 @@
%global namedreltag .Final
%global namedversion %{version}%{?namedreltag}
Name: jboss-logging
Version: 3.5.3
Release: 5%{?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: 0002-Drop-jboss-logmanager-dependency.patch
Patch3: 0003-Drop-TestCase-that-depend-on-retired-package.patch
BuildArch: noarch
ExclusiveArch: %{java_arches} noarch
BuildRequires: maven-local
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.junit:junit-bom:pom:)
BuildRequires: mvn(org.apache.logging:logging-parent:pom:)
BuildRequires: mvn(org.slf4j:slf4j-api)
%description
This package contains the JBoss Logging Framework.
%prep
%autosetup -n %{name}-%{namedversion} -p 1
# 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
%pom_set_parent org.apache.logging:logging-parent
%build
%mvn_build -j
%install
%mvn_install
%files -f .mfiles
%license LICENSE.txt
%changelog
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 3.5.3-5
- Bump release for June 2024 mass rebuild
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jan 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Mon Jul 10 2023 Chris Kelley <ckelley@redhat.com> - 3.5.3-1
- Rebase to version 3.5.3.Final
* Fri Jun 30 2023 Chris Kelley <ckelley@redhat.com> - 3.5.2-1
- Rebase to version 3.5.2.Final
* 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
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Fri Jul 08 2022 Jiri Vanek <jvanek@redhat.com> - 3.4.1-12
- Rebuilt for Drop i686 JDKs
* Sat Feb 05 2022 Jiri Vanek <jvanek@redhat.com> - 3.4.1-11
- Rebuilt for java-17-openjdk as system jdk
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Jun 04 2021 Dogtag PKI Team <pki-devel@redhat.com> - 3.4.1-8
- Drop jboss-logmanager dependency
* Fri Jun 04 2021 Dogtag PKI Team <pki-devel@redhat.com> - 3.4.1-7
- Drop log4j dependency
- Drop jboss-logging-javadoc
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Sep 09 2020 Fabio Valentini <decathorpe@gmail.com> - 3.4.1-5
- Switch from log4j 1.2 compat package to log4j 1.2 API shim.
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jul 10 2020 Jiri Vanek <jvanek@redhat.com> - 3.4.1-3
- Rebuilt for JDK-11, see https://fedoraproject.org/wiki/Changes/Java11
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Sat Oct 05 2019 Fabio Valentini <decathorpe@gmail.com> - 3.4.1-1
- Update to version 3.4.1.
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Fri May 27 2016 gil cattaneo <puntogil@libero.it> 3.3.0-1
- update to 3.3.0.Final
* Sun Feb 14 2016 gil cattaneo <puntogil@libero.it> 3.1.4-6
- fix FTBFS rhbz#1307647
- fix BR list and use BR mvn()-like
- introduce license macro
- fix some rpmlint problem
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Tue Jul 01 2014 Marek Goldmann <mgoldman@redhat.com> - 3.1.4-3
- Upgrade to SLF4j 1.7
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Fri Feb 14 2014 Marek Goldmann <mgoldman@redhat.com> - 3.1.4-1
- Upstream release 3.1.4.GA
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Fri Jun 28 2013 Marek Goldmann <mgoldman@redhat.com> - 3.1.3-1
- Upstream release 3.1.3.GA
* Tue Feb 26 2013 Marek Goldmann <mgoldman@redhat.com> - 3.1.2-1
- Upstream release 3.1.2.GA
- Move to mvn_build and mvn_install macros
- License change to ASL 2.0
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Wed Feb 06 2013 Java SIG <java-devel@lists.fedoraproject.org> - 3.1.0-5
- Update for https://fedoraproject.org/wiki/Fedora_19_Maven_Rebuild
- Replace maven BuildRequires with maven-local
* Fri Jul 20 2012 Marek Goldmann <mgoldman@redhat.com> - 3.1.0-4
- Fixed BR
* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Sun Feb 26 2012 Marek Goldmann <mgoldman@redhat.com> 3.1.0-2
- Release bump
* Sun Feb 26 2012 Marek Goldmann <mgoldman@redhat.com> 3.1.0-1
- Upstream release 3.1.0.GA
- Relocated jars to _javadir
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.0-0.2.CR1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Fri Nov 18 2011 Marek Goldmann <mgoldman@redhat.com> 3.1.0-0.1.CR1
- Upstream release 3.1.0.CR1
* Mon Sep 19 2011 Marek Goldmann <mgoldman@redhat.com> 3.0.1-1
- Upstream release 3.0.1.GA
* Thu Jul 28 2011 Marek Goldmann <mgoldman@redhat.com> 3.0.0-1
- Initial packaging

View File

@ -1 +0,0 @@
SHA512 (jboss-logging-3.5.3.Final.tar.gz) = 600880c78974fca193c845e1f90bbb123e97354eda39e3b5d2cd962fbc2d7f1d108481c2b736d193a2400eed66fa75b111bee27a8335f9b52a0bc52e6ef6c1e9