Fix stray log lines in version.sh/version.bat output - #1057
Open
csutherl wants to merge 1 commit into
Open
Conversation
Probing the optional native/OpenSSL libraries in ServerInfo.main() triggers their initialization, which logged java.util.logging messages into the version output. The previous fix lowered two parent loggers to WARNING, but WARNING did not suppress the SEVERE "incompatible Tomcat Native version" message, and no strong reference was kept to the loggers so the configured level could be garbage collected before the init code logged. Instead, attach a capturing handler to the loggers involved with useParentHandlers=false so nothing reaches the console, retaining strong references to avoid the weak-reference GC issue. The captured incompatible-version message is re-emitted under "APR loaded: false" so that outcome is no longer unexplained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| * the capturing handler and {@code useParentHandlers=false} configured on | ||
| * it) before the library initialization code logs. | ||
| */ | ||
| private static final List<Logger> capturedLoggers = new ArrayList<>(); |
Contributor
There was a problem hiding this comment.
Is it possible to disable this thing ?
Contributor
|
This does seem to be of those things that sounds simple but quickly ends up needing a fair amount of code. If not overly concerned, providing there are users that find this information useful. Generally, I would lean towards providing information on why something failed if we can. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Probing the optional native/OpenSSL libraries in
ServerInfo.main()triggers their initialization, which loggedjava.util.loggingmessages into the version output. The last attempt to address this lowered two parent loggers to WARNING, but WARNING did not suppress the SEVERE "incompatible Tomcat Native version" message, and no strong reference was kept to the loggers so the configured level could be garbage collected before the init code logged.This change adds a capturing handler to the loggers involved with
useParentHandlers=falseso nothing reaches the console, retaining strong references to avoid the weak-reference GC issue. Then the captured incompatible-version message from tomcat-native is re-emitted under "APR loaded: false" so that outcome is no longer unexplained and gives a clear action step before they may run into the problem at runtime.As an alternate approach that's much simpler we could simply ignore the WARN and output
APR loaded: falsewithout any additional information for the user. Thoughts?