-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
[ZOOKEEPER-4820] Fix propagation of Logback dependencies #2155
[ZOOKEEPER-4820] Fix propagation of Logback dependencies #2155
Conversation
Java libraries should not have `runtime` dependencies on logging backends, since they are often included in third-party applications that might make a different choice of backend. This PR: * removes the Logback dependency from the runtime scope of the `zookeeper` artifact and moves it into the `test` Maven scope, * adds Logback to `zookeeper-assembly`, which is used to produce the standalone [binary distribution](https://zookeeper.apache.org/releases) available on Zookeeper's site.
maybe we can mark this dependency as runtime optional instead of test? |
Personally I am not a big fan of Inside the Zookeeper project their usefulness is also somehow limited: the Maven Compiler and Surefire plugins will use them, but the Maven Assembly plugin will not package them in the So the only difference between runtime Remark: The way Logback is treated in this PR is similar to the Jetty dependency. Jetty is included in the |
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 have a preference for optional runtime, but this works too.
It affects behavior, so I would not say it's documentation only. But even if it were, there is value in documentation... in communicating intent to downstream consumers of the project.
Maven actually defines the meaning of these. I think your interpretation is pretty much correct, because it aligns with these definitions, but I don't think it's as subjective as you suggest. These definitions are what developers use to implement behavioral differences. Optional just means you have the option to exclude it and that Maven does so by default. It doesn't say anything about what behavioral changes might result or what you might require in its place, though, if you choose to exclude it. For that, you kind of have to know something about what is being excluded and why. A little understanding of Java logging frameworks like slf4j close this gap, though, and it will be clear to most users that the runtime implementation of slf4j is interchangeable, and that's why this implementation is optional. So, I don't think it'd be a problem to mark it as optional.
I would say "happens to use" rather than "prefers/recommends", but yes, I think that message is basically the right message. But I think that message can be communicated with optional, and a basic understanding of Java logging frameworks.
This is not true. There's actually no difference here. If it's marked optional alone, but still in the default "compile" scope, it will be available at compilation time. However, if it's marked "runtime", it is not available at compilation time... only test. That's why "optional" is frequently used in conjunction with "runtime" scope. So, there's actually no difference in behavior between these... it really just comes down to communicating intent.
This is a strange comparison, because jetty is actually marked as provided, which puts it on the compile and runtime classpaths. So, contrary to what you just said, there actually is a runtime dependency for it. I would actually argue that these should just be regular compile (or runtime) dependencies, though, and not marked provided, since it's probably not expected that jetty will be provided by another project, since it's provided by this one. But that's outside the scope of this change. In any case, because ZooKeeper does actually have a compile time dependency on logback for its tests, I think marking it as a test dependency is fine, since it achieves the same thing as a runtime optional dependency, but I would still prefer runtime optional over test, because it communicates that something is being omitted from the runtime scope that may need to be added in order to achieve particular functionality (logging). |
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 see it was changed while I was replying to the other comment. I like this better for the reasons I've stated (I think it communicates intent better), but I do concede that marking it as test scope could have also worked.
Inside the Zookeeper project I agree: there are behavioral differences. But if Zookeeper is used as a dependency in another project, the differences fade.
Yes, it makes sense. I might steal your interpretation and add an optional runtime dependency on Logback to
Sorry, I was thinking |
LOG4J2-3601 was a problem because:
I suspect adding logback as an optional runtime dependency to |
I did notice that there's a failing test, I'm not sure if the test was failing before this. But, it doesn't look like a good test. It looks like it's testing the logging framework itself... which is outside the scope of ZK. That's a kind of test I would expect from upstream in the logging library. It makes no sense to be included in the zookeeper inspector contrib tests, since it has nothing to do with ZK or the inspector contrib. I would recommend just deleting the test. It's not needed, and serves no purpose for ZK. |
Sorry, one more comment: looking at this closely, it looks like some updates might be needed to fix the logging dependencies in the contrib poms, too. They might also need similar changes as |
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.
with this change are you able to see the logs while running the unit tests ?
Is there any action on this? This genuinely is an issue for me, I updated zookeeper version and suddenly my tests produced a few hundred mb of debug logs, because of the logback-classic implementation having debug as the default log level. I do know how to resolve it for myself, but I wouldn't want users of my library to have same problem (and I can't rely on maven excludes etc.) |
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.
Looks good to me
Yes. I confirmed this. cc @eolivelli |
This looks like it was done and reviewed favorably, but never actually merged. |
Reviewers: ctubbsii, shoothzj, ctubbsii, kezhuw Author: ppkarwasz Closes #2155 from ppkarwasz/fix/4820_change_logback_scope (cherry picked from commit ff2406d) Signed-off-by: Andor Molnar <[email protected]>
@ctubbsii Cool, thanks for the heads-up. I'm happy to commit patches for the upcoming 3.9.3 release. |
I don't have enough permissions on JIRA to assign ZOOKEEPER issues. 😉 |
What's your jira id? |
|
It's done. Thanks! |
Java libraries should not have
runtime
dependencies on logging backends, since they are often included in third-party applications that might make a different choice of backend.This PR:
zookeeper
artifact and moves it into thetest
Maven scope,zookeeper-assembly
, which is used to produce the standalone binary distribution available on Zookeeper's site.