-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Disable Log4J JMX beans creation in tests to avoid overhead #3753
Disable Log4J JMX beans creation in tests to avoid overhead #3753
Conversation
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.
I guess this is a "best practice" from a security perspective, right? If so, we should also document it in the User Guide, shouldn't we?
junit5/documentation/src/docs/asciidoc/user-guide/running-tests.adoc
Lines 243 to 245 in e160aec
test { | |
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager") | |
} |
Security, memory footprint, and faster initialization: https://logging.apache.org/log4j/2.x/manual/jmx.html#enabling-jmx
Personally, I would have preferred if the default was
I could modify the example you quoted to: a) test {
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
// https://logging.apache.org/log4j/2.x/manual/jmx.html#enabling-jmx
systemProperty("log4j2.disableJmx", "true")
} b) test {
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
// disable log4j2 JMX beans for security reasons
systemProperty("log4j2.disableJmx", "true")
} Unfortunately, each framework has its own way of doing so—I am not sure if the "how-to" belongs in the JUnit documentation. "Someplace" we could add a note that it is a good idea to disable JMX bean creation for:
As far as I am aware, there is also no official way to turn off JMX functionality on the JVM level. |
Let's go with something generic like this: test {
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
// Avoid overhead (see https://logging.apache.org/log4j/2.x/manual/jmx.html#enabling-jmx)
systemProperty("log4j2.disableJmx", "true")
}
I think this is outside the scope of the JUnit docs so I'd omit that for now. |
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.
see #3753 (comment)
fix #3751 Signed-off-by: Sebastian Davids <sdavids@gmx.de>
I have updated this PR. I will create a PR in the log4j2 repo to disable JMX bean creation by default. see: Depending on the outcome of the other PR we can close or merge this one. Alternatively, we can merge this one now and I would create a new PR to revert this one, if necessary. Up to you … |
Thanks! I decided to rather merge it now than keeping it open. Disabling it by default in Log4J would be a great outcome! 👍 |
https://github.com/apache/logging-log4j2/releases/tag/rel%2F2.24.0
|
Should I author a PR reverting this one?
⇓
|
Overview
fix #3751
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations