diff --git a/0001-Drop-log4j-dependency.patch b/0001-Drop-log4j-dependency.patch new file mode 100644 index 0000000..baad179 --- /dev/null +++ b/0001-Drop-log4j-dependency.patch @@ -0,0 +1,473 @@ +From 8f6cddf7a01add25a5bddaef26914b6c6082cddc 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 + +--- + 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 | 16 +--- + 6 files changed, 2 insertions(+), 387 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 + +diff --git a/pom.xml b/pom.xml +index 60a9de3..88af23f 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -31,8 +31,6 @@ + + + +- 1.2.16 +- 2.11.2 + 2.1.9.Final + 1.7.25 + +@@ -44,28 +42,6 @@ + ${version.org.jboss.logmanager} + provided + +- +- log4j +- log4j +- ${version.org.apache.log4j} +- provided +- +- +- com.sun.jdmk +- jmxtools +- +- +- com.sun.jmx +- jmxri +- +- +- +- +- org.apache.logging.log4j +- log4j-api +- ${version.org.apache.logging.log4j} +- provided +- + + org.slf4j + slf4j-api +@@ -109,7 +85,6 @@ + ${project.groupId}.*;version=${project.version};-split-package:=error + + +- org.apache.log4j.config;resolution:=optional, + *;resolution:=optional + + +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 +--- a/src/main/java/org/jboss/logging/Log4j2Logger.java ++++ /dev/null +@@ -1,92 +0,0 @@ +-/* +- * JBoss, Home of Professional Open Source. +- * +- * Copyright 2013 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(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 84417d2..0000000 +--- a/src/main/java/org/jboss/logging/Log4j2LoggerProvider.java ++++ /dev/null +@@ -1,96 +0,0 @@ +-/* +- * JBoss, Home of Professional Open Source. +- * +- * Copyright 2013 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; +- +-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 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 3f7a3f2..0000000 +--- a/src/main/java/org/jboss/logging/Log4jLogger.java ++++ /dev/null +@@ -1,74 +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.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 69bdd5f..0000000 +--- a/src/main/java/org/jboss/logging/Log4jLoggerProvider.java ++++ /dev/null +@@ -1,86 +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.util.Collections; +-import java.util.Map; +- +-import org.apache.log4j.MDC; +-import org.apache.log4j.NDC; +- +-final class Log4jLoggerProvider implements LoggerProvider { +- +- public Logger getLogger(final String name) { +- return new Log4jLogger("".equals(name) ? "ROOT" : name); +- } +- +- public void clearMdc() { +- MDC.clear(); +- } +- +- public Object getMdc(String key) { +- return MDC.get(key); +- } +- +- public Map getMdcMap() { +- @SuppressWarnings("unchecked") +- final Map map = MDC.getContext(); +- return map == null ? Collections.emptyMap() : map; +- } +- +- public Object putMdc(String key, Object val) { +- try { +- return MDC.get(key); +- } finally { +- MDC.put(key, val); +- } +- } +- +- public void removeMdc(String key) { +- MDC.remove(key); +- } +- +- public void clearNdc() { +- NDC.remove(); +- } +- +- public String getNdc() { +- return NDC.get(); +- } +- +- public int getNdcDepth() { +- return NDC.getDepth(); +- } +- +- public String peekNdc() { +- return NDC.peek(); +- } +- +- public String popNdc() { +- return NDC.pop(); +- } +- +- public void pushNdc(String message) { +- NDC.push(message); +- } +- +- 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..798c56b 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 { + + // 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; ++ return null; + } + + 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; ++ return null; + } + + private static LoggerProvider tryJBossLogManager(final ClassLoader cl, final String via) throws ClassNotFoundException { +-- +2.31.1 + diff --git a/jboss-logging.spec b/jboss-logging.spec index 61ac477..c15e0be 100644 --- a/jboss-logging.spec +++ b/jboss-logging.spec @@ -3,19 +3,18 @@ Name: jboss-logging Version: 3.4.1 -Release: 6%{?dist} +Release: 7%{?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 BuildArch: noarch BuildRequires: maven-local BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) -BuildRequires: mvn(org.apache.logging.log4j:log4j-1.2-api) -BuildRequires: mvn(org.apache.logging.log4j:log4j-api) BuildRequires: mvn(org.jboss:jboss-parent:pom:) BuildRequires: mvn(org.jboss.logmanager:jboss-logmanager) BuildRequires: mvn(org.slf4j:slf4j-api) @@ -30,14 +29,11 @@ Summary: Javadoc for %{name} This package contains the API documentation for %{name}. %prep -%setup -q -n %{name}-%{namedversion} +%autosetup -n %{name}-%{namedversion} -p 1 # Unneeded task %pom_remove_plugin :maven-source-plugin -# switch from log4j 1.2 compat package to log4j 1.2 API shim -%pom_change_dep log4j:log4j org.apache.logging.log4j:log4j-1.2-api - cp -p src/main/resources/META-INF/LICENSE.txt . sed -i 's/\r//' LICENSE.txt @@ -54,6 +50,9 @@ sed -i 's/\r//' LICENSE.txt %license LICENSE.txt %changelog +* Fri Jun 04 2021 Dogtag PKI Team - 3.4.1-7 +- Drop log4j dependency + * Tue Jan 26 2021 Fedora Release Engineering - 3.4.1-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild