-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix Slf4j providers not found error #2420
base: master
Are you sure you want to change the base?
Conversation
@Torch3333 Can you tell me how to reproduce the warning message? |
@komamitsu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
@Torch3333 Ah, this change might break backward compatibility. For example, if a user is using log4j with slf4j implementation "org.slf4j:slf4j-api:1.7.36"
implementation "org.apache.logging.log4j:log4j-core:2.24.3"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:2.24.3" However, if a user is using log4j with slf4j implementation "org.slf4j:slf4j-api:2.0.16"
implementation "org.apache.logging.log4j:log4j-core:2.24.3"
implementation "org.apache.logging.log4j:log4j-slf4j2-impl:2.24.3" Therefore, if we upgrade slf4j to |
@brfrn169 @komamitsu I went with a different approach and set up Gradle to force the usage of the slf4j version set by ScalarDB over any transitively pulled version. PTAL. 🙇 |
IIUC, the new way makes the library (
I'm not sure if we need to continue using 1.x forever. I think our customers and we need to upgrade the dependency someday... |
@komamitsu I think we can upgrade in the next major version ( |
build.gradle
Outdated
@@ -89,5 +89,9 @@ subprojects { | |||
installDist { | |||
duplicatesStrategy DuplicatesStrategy.EXCLUDE | |||
} | |||
|
|||
configurations.all { | |||
resolutionStrategy.force "org.slf4j:slf4j-api:${slf4jVersion}", "org.slf4j:slf4j-simple:${slf4jVersion}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, how about excluding the slf4j
dependency from the mariadb
dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I think excluding it is a bit more polite way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can.
I thought that using the resolutionStrategy.force
was future-proof in case another library we update pulls slf4j
v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Gradle doc explains that using the resolutionStrategy.force
is a project-global excluding rule.
Excluding a particular transitive dependency does not guarantee that it does not show up in the dependencies of a given configuration. For example, some other dependency, which does not have any exclude rules, might pull in exactly the same transitive dependency. To guarantee that the transitive dependency is excluded from the entire configuration please use per-configuration exclude rules: [getExcludeRules](https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.artifacts/-configuration/get-exclude-rules.html). In fact, in a majority of cases the actual intention of configuring per-dependency exclusions is really excluding a dependency from the entire configuration (or classpath).
If your intention is to exclude a particular transitive dependency because you don't like the version it pulls in to the configuration then consider using forced versions' feature: [force](https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.artifacts/-resolution-strategy/force.html).
Could you share your concerns concerning the resolutionStrategy.force
?
I am ok with using either method but I just want to better understand your point of view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 2 ways have similar effects, and actually either is fine with me. IIUC, the slight difference is basically only global-scope or not. So, this might be also a matter of taste thing. I relatively prefer starting with small-scope effect, but I don't insist on it as I understand the pros of resolutionStrategy.force
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was concerned about the side effects of resolutionStrategy.force
since it’s a project-global configuration. Also, I believe we’ve usually used the exclude
configuration for similar issues in the past. Do you think resolutionStrategy.force
is a better approach than the exclude
configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that resolutionStrategy.force
could be used as project-wide exclude
which means:
- The forced dependency version was used project-wide when building ScalarDB
- Other projects using ScalarDB as a dependency would also be presented with the forced dependency version, i.e. excluding the non-wanted version
But after testing locally, statement 2. is wrong. slf4j-api:2.0.7
was still listed as a transitive dependency of com.github.waffle:waffle-jna
when using ScalarDB as an implementation dependency on a Gradle project.
In comparison, when using the exclude
syntax. slf4j-api:2.0.7
was not listed as a dependency or pulled by com.github.waffle:waffle-jna
when using ScalarDB as an implementation dependency on a Gradle project.
This is what we want to avoid the problem described by Toshi in #2420 (comment)
So, I will revise the PR to use the exclude syntax.
Sounds okay!
(cc: @Torch3333) BTW, I checked the source code of |
Ok, thank you for taking the time to check! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
Description
This updates slf4j to the latest version to resolve the following logger binding issue when running ScalarDB unit or integration test.This forces Gradle to use the slf4j version defined by ScalarDB over any version pulled transitively.
This problem appeared after adding the MariaDB driver dependency in #2391. This dependency pulls
slf4j-api
version 2.X, butsl4j-simple
stays with version 1.7.X, causing a mismatch.Related issues and/or PRs
N/A
Changes made
Update slf4j to the latest version.
Checklist
Additional notes (optional)
N/A
Release note
N/A