You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2022/07/13 06:58:38 UTC
[pulsar] branch master updated: [improve][dependency] Remove jul-to-slf4j (#16320)
This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 303038aa2d3 [improve][dependency] Remove jul-to-slf4j (#16320)
303038aa2d3 is described below
commit 303038aa2d3d1f15c545c615a19c9dfbb0100c1a
Author: tison <wa...@gmail.com>
AuthorDate: Wed Jul 13 14:58:30 2022 +0800
[improve][dependency] Remove jul-to-slf4j (#16320)
### Motivation
see also https://lists.apache.org/thread/65skwo492w2nfjwhb3d9y51roq13h8bs
PulsarAdminImpl has a static block requires classpath contains exact either of:
* slf4j-jdk14
* jul-to-slf4j
It causes an issue that if user depends on neither slf4j-jdk14 nor jul-to-slf4j, PulsarAdminImpl will panic with NoClassDefFoundError. And thus, user should add one of them (basically jul-to-slf4j) even if they don't depend on it effectively.
### Modifications
Remove jul-to-slf4j from all modules under Pulsar.
The Pulsar project uses slf4j as the logging facade consistently. If a user want to add a dependency using a different logging framework, they should take care of the packaging strategy themselves.
pulsar-sql has a dependency to slf4j-jdk14 which redirect slf4j to jul. Since this is a unidirectional redirection, it won't cause runtime error, but pulsar-sql will logging with jul framework, which is the same as with previous workaround.
---
distribution/server/src/assemble/LICENSE.bin.txt | 1 -
pom.xml | 6 ------
pulsar-broker/pom.xml | 5 -----
.../java/org/apache/pulsar/PulsarBrokerStarter.java | 3 ---
pulsar-client-admin/pom.xml | 5 -----
.../pulsar/client/admin/internal/PulsarAdminImpl.java | 19 -------------------
pulsar-proxy/pom.xml | 5 -----
.../pulsar/proxy/server/ProxyServiceStarter.java | 7 -------
pulsar-sql/presto-distribution/LICENSE | 2 --
pulsar-websocket/pom.xml | 5 -----
10 files changed, 58 deletions(-)
diff --git a/distribution/server/src/assemble/LICENSE.bin.txt b/distribution/server/src/assemble/LICENSE.bin.txt
index ba3b7aa05d8..34a3ca422b0 100644
--- a/distribution/server/src/assemble/LICENSE.bin.txt
+++ b/distribution/server/src/assemble/LICENSE.bin.txt
@@ -558,7 +558,6 @@ BSD 2-Clause License
MIT License
* Java SemVer -- com.github.zafarkhaja-java-semver-0.9.0.jar -- licenses/LICENSE-SemVer.txt
* SLF4J -- licenses/LICENSE-SLF4J.txt
- - org.slf4j-jul-to-slf4j-1.7.32.jar
- org.slf4j-slf4j-api-1.7.32.jar
- org.slf4j-jcl-over-slf4j-1.7.32.jar
* The Checker Framework
diff --git a/pom.xml b/pom.xml
index a7fb7680e89..50a7217da71 100644
--- a/pom.xml
+++ b/pom.xml
@@ -691,12 +691,6 @@ flexible messaging model and an intuitive client API.</description>
<version>${slf4j.version}</version>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
diff --git a/pulsar-broker/pom.xml b/pulsar-broker/pom.xml
index d2641319e85..5cd9b9bf845 100644
--- a/pulsar-broker/pom.xml
+++ b/pulsar-broker/pom.xml
@@ -267,11 +267,6 @@
<artifactId>jackson-module-jsonSchema</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
index cac23d5166d..88695ae8380 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
@@ -62,13 +62,10 @@ import org.apache.pulsar.functions.worker.WorkerService;
import org.apache.pulsar.functions.worker.service.WorkerServiceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.bridge.SLF4JBridgeHandler;
public class PulsarBrokerStarter {
private static ServiceConfiguration loadConfig(String configFile) throws Exception {
- SLF4JBridgeHandler.removeHandlersForRootLogger();
- SLF4JBridgeHandler.install();
try (InputStream inputStream = new FileInputStream(configFile)) {
ServiceConfiguration config = create(inputStream, ServiceConfiguration.class);
// it validates provided configuration is completed
diff --git a/pulsar-client-admin/pom.xml b/pulsar-client-admin/pom.xml
index 031590bd3c9..89fccfccd56 100644
--- a/pulsar-client-admin/pom.xml
+++ b/pulsar-client-admin/pom.xml
@@ -92,11 +92,6 @@
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
-
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
diff --git a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminImpl.java b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminImpl.java
index 427ab6d1aff..dbfaf9af761 100644
--- a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminImpl.java
+++ b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminImpl.java
@@ -65,7 +65,6 @@ import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.bridge.SLF4JBridgeHandler;
/**
* Pulsar client admin API client.
@@ -114,24 +113,6 @@ public class PulsarAdminImpl implements PulsarAdmin {
private final int requestTimeout;
private final TimeUnit requestTimeoutUnit;
- static {
- /**
- * The presence of slf4j-jdk14.jar, that is the jul binding for SLF4J, will force SLF4J calls to be delegated to
- * jul. On the other hand, the presence of jul-to-slf4j.jar, plus the installation of SLF4JBridgeHandler, by
- * invoking "SLF4JBridgeHandler.install()" will route jul records to SLF4J. Thus, if both jar are present
- * simultaneously (and SLF4JBridgeHandler is installed), slf4j calls will be delegated to jul and jul records
- * will be routed to SLF4J, resulting in an endless loop. We avoid this loop by detecting if slf4j-jdk14 is used
- * in the client class path. If slf4j-jdk14 is found, we don't use the slf4j bridge.
- */
- try {
- Class.forName("org.slf4j.impl.JDK14LoggerFactory");
- } catch (Exception ex) {
- // Setup the bridge for java.util.logging to SLF4J
- SLF4JBridgeHandler.removeHandlersForRootLogger();
- SLF4JBridgeHandler.install();
- }
- }
-
public PulsarAdminImpl(String serviceUrl, ClientConfigurationData clientConfigData) throws PulsarClientException {
this(serviceUrl, clientConfigData, DEFAULT_CONNECT_TIMEOUT_SECONDS, TimeUnit.SECONDS,
DEFAULT_READ_TIMEOUT_SECONDS, TimeUnit.SECONDS, DEFAULT_REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS,
diff --git a/pulsar-proxy/pom.xml b/pulsar-proxy/pom.xml
index 060d4c45f21..103e816497f 100644
--- a/pulsar-proxy/pom.xml
+++ b/pulsar-proxy/pom.xml
@@ -125,11 +125,6 @@
<artifactId>javax.activation</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
-
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyServiceStarter.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyServiceStarter.java
index 1d966f05950..11082758c9a 100644
--- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyServiceStarter.java
+++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyServiceStarter.java
@@ -23,8 +23,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.pulsar.common.stats.JvmMetrics.getJvmDirectMemoryUsed;
-import static org.slf4j.bridge.SLF4JBridgeHandler.install;
-import static org.slf4j.bridge.SLF4JBridgeHandler.removeHandlersForRootLogger;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.google.common.annotations.VisibleForTesting;
@@ -107,11 +105,6 @@ public class ProxyServiceStarter {
public ProxyServiceStarter(String[] args) throws Exception {
try {
-
- // setup handlers
- removeHandlersForRootLogger();
- install();
-
DateFormat dateFormat = new SimpleDateFormat(
FixedDateFormat.FixedFormat.ISO8601_OFFSET_DATE_TIME_HHMM.getPattern());
Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
diff --git a/pulsar-sql/presto-distribution/LICENSE b/pulsar-sql/presto-distribution/LICENSE
index 7a07543640c..cd19bb308c7 100644
--- a/pulsar-sql/presto-distribution/LICENSE
+++ b/pulsar-sql/presto-distribution/LICENSE
@@ -508,8 +508,6 @@ MIT License
- slf4j-jdk14-1.7.32.jar
* JCL 1.2 Implemented Over SLF4J
- jcl-over-slf4j-1.7.32.jar
- * JUL to SLF4J Bridge
- - jul-to-slf4j-1.7.32.jar
* Checker Qual
- checker-qual-3.12.0.jar
* Annotations
diff --git a/pulsar-websocket/pom.xml b/pulsar-websocket/pom.xml
index cf9d9865bcd..e5a392f3f9b 100644
--- a/pulsar-websocket/pom.xml
+++ b/pulsar-websocket/pom.xml
@@ -87,11 +87,6 @@
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
-
<!-- To write basic websockets against -->
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>