diff --git a/0001-Drop-jboss-logmanager-dependency.patch b/0001-Drop-jboss-logmanager-dependency.patch new file mode 100644 index 0000000..071e016 --- /dev/null +++ b/0001-Drop-jboss-logmanager-dependency.patch @@ -0,0 +1,332 @@ +From 83f101442cc126dab0ff4bf793f4ed518ff5df19 Mon Sep 17 00:00:00 2001 +From: "Endi S. Dewata" +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 @@ + + + +- 2.1.9.Final + 1.7.25 + + + +- +- org.jboss.logmanager +- jboss-logmanager +- ${version.org.jboss.logmanager} +- provided +- + + org.slf4j + slf4j-api +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 KEY = new AttachmentKey(); +- private static final AttachmentKey> LEGACY_KEY = new AttachmentKey>(); +- +- public Logger getLogger(final String name) { +- final SecurityManager sm = System.getSecurityManager(); +- if (sm != null) { +- return AccessController.doPrivileged(new PrivilegedAction() { +- 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 loggers = lmLogger.getAttachment(LEGACY_KEY); +- if (loggers == null) { +- loggers = new ConcurrentHashMap(); +- final ConcurrentMap 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 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 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 + diff --git a/0001-Drop-log4j-dependency.patch b/0001-Drop-log4j-dependency.patch index baad179..c833cd9 100644 --- a/0001-Drop-log4j-dependency.patch +++ b/0001-Drop-log4j-dependency.patch @@ -1,4 +1,4 @@ -From 8f6cddf7a01add25a5bddaef26914b6c6082cddc Mon Sep 17 00:00:00 2001 +From db9a311cb2bf17f9febdf5e31d28ca83af399cf9 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 4 Jun 2021 12:20:45 -0500 Subject: [PATCH] Drop log4j dependency @@ -9,8 +9,8 @@ Subject: [PATCH] Drop log4j dependency .../jboss/logging/Log4j2LoggerProvider.java | 96 ------------------- .../java/org/jboss/logging/Log4jLogger.java | 74 -------------- .../jboss/logging/Log4jLoggerProvider.java | 86 ----------------- - .../org/jboss/logging/LoggerProviders.java | 16 +--- - 6 files changed, 2 insertions(+), 387 deletions(-) + .../org/jboss/logging/LoggerProviders.java | 36 ------- + 6 files changed, 409 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 @@ -439,13 +439,44 @@ index 69bdd5f..0000000 - } -} diff --git a/src/main/java/org/jboss/logging/LoggerProviders.java b/src/main/java/org/jboss/logging/LoggerProviders.java -index 0608283..798c56b 100644 +index 0608283..8e393d1 100644 --- a/src/main/java/org/jboss/logging/LoggerProviders.java +++ b/src/main/java/org/jboss/logging/LoggerProviders.java -@@ -115,23 +115,11 @@ final class LoggerProviders { +@@ -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"); + } +@@ -80,17 +76,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 { + return provider; + } - // JBLOGGING-95 - Add support for Log4j 2.x - private static LoggerProvider tryLog4j2(final ClassLoader cl, final String via) throws ClassNotFoundException { +- // 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); @@ -453,10 +484,9 @@ index 0608283..798c56b 100644 - // 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; -+ return null; - } - - private static LoggerProvider tryLog4j(final ClassLoader cl, final String via) throws ClassNotFoundException { +- } +- +- 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 @@ -464,10 +494,11 @@ index 0608283..798c56b 100644 - final LoggerProvider provider = new Log4jLoggerProvider(); - logProvider(provider, via); - return provider; -+ return null; - } - +- } +- private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException { + final Class logManagerClass = LogManager.getLogManager().getClass(); + if (logManagerClass == Class.forName("org.jboss.logmanager.LogManager", false, cl) -- 2.31.1 diff --git a/jboss-logging.spec b/jboss-logging.spec index 23b50d1..bfb3234 100644 --- a/jboss-logging.spec +++ b/jboss-logging.spec @@ -3,20 +3,20 @@ Name: jboss-logging Version: 3.4.1 -Release: 7%{?dist} +Release: 8%{?dist} Summary: The JBoss Logging Framework License: ASL 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 BuildArch: noarch BuildRequires: maven-local BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) BuildRequires: mvn(org.jboss:jboss-parent:pom:) -BuildRequires: mvn(org.jboss.logmanager:jboss-logmanager) BuildRequires: mvn(org.slf4j:slf4j-api) %description @@ -41,6 +41,9 @@ sed -i 's/\r//' LICENSE.txt %license LICENSE.txt %changelog +* Fri Jun 04 2021 Dogtag PKI Team - 3.4.1-8 +- Drop jboss-logmanager dependency + * Fri Jun 04 2021 Dogtag PKI Team - 3.4.1-7 - Drop log4j dependency - Drop jboss-logging-javadoc