Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: exclude transitive logback dependencies #2175

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

robobario
Copy link
Contributor

@robobario robobario commented Jul 23, 2024

Exclude logback from being depended on transitively (following established pattern for excluding log4j:log4j)

Why:
A logback slf4j binding is being pulled in via zookeeper causing issues at runtime because we have two slf4j bindings available. Slf4j chooses one implementation and it can pick logback, which is unexpected.

To reproduce on main:

gradle clean build -q -x test && ./kafka-cruise-control-start.sh config/cruisecontrol.properties 2>&1 | grep SLF4J
... gradle noises ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

This PR resolves #2174

A logback slf4j binding is being pulled in via zookeeper causing issues
at runtime because we have two slf4j bindings available. Slf4j chooses
one implementation and it can pick logback, which is unexpected.

Fixes linkedin#2174

Signed-off-by: Robert Young <[email protected]>
Copy link
Contributor

@fvaleri fvaleri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@mhratson
Copy link
Contributor

Tested locally, with patch the transitive dependencies aren't being picked up:
Before

$ ./kafka-cruise-control-start.sh ./cruisecontrol.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/mhratson/src/cruise-control.3/cruise-control/build/dependant-libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/mhratson/src/cruise-control.3/cruise-control/build/dependant-libs/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

After (no multiple bindings logs)

$ ./kafka-cruise-control-start.sh ./cruisecontrol.properties 
[2024-07-24 16:27:26,064] INFO COMMIT INFO: 2.5.139-SNAPSHOT---f23332a2ec4f8f3f0d69cd6e6f3b7aa9e33fb873 (com.linkedin.kafka.cruisecontrol.KafkaCruiseControl)
[2024-07-24 16:27:26,069] INFO AdminClientConfig values: 
	auto.include.jmx.reporter = true

Copy link
Contributor

@mhratson mhratson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@mhratson mhratson merged commit 6440412 into linkedin:main Jul 24, 2024
2 checks passed
mborst pushed a commit to DataDog/cruise-control that referenced this pull request Sep 19, 2024
Exclude logback from being depended on transitively (following established pattern for excluding log4j:log4j)

Why:
A logback slf4j binding is being pulled in via zookeeper causing issues at runtime because we have two slf4j bindings available. Slf4j chooses one implementation and it can pick logback, which is unexpected.

To reproduce on `main`:

```
gradle clean build -q -x test && ./kafka-cruise-control-start.sh config/cruisecontrol.properties 2>&1 | grep SLF4J
... gradle noises ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
```

This PR resolves linkedin#2174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple SLF4j bindings in class path
3 participants