Fix #1001: Suppress spurious warning when including classpath config files without scan - #1037
Open
lukman48 wants to merge 1 commit into
Open
Conversation
…onfig files without scan When a resource is included via <include resource="file.xml"/> without scan="true", logback would log an unnecessary INFO message about ConfigurationWatchList not being initialized. This produces spurious warnings in logs even though everything works correctly. Root cause: The addToWatchList() method was logging a message whenever ConfigurationWatchList was null, regardless of whether file monitoring was actually enabled. Solution: Only log the message when createCWL=true (which indicates that an attempt was made to create a watch list). When createCWL=false (the default for <include> elements), silently return without logging, as file monitoring is not enabled and the classpath resource cannot be monitored anyway. Benefits: - Cleaner logs: no spurious messages when scan="false" (the default) - Expected behavior: resources from classpath without scan directive don't log warnings - Maintains backward compatibility: existing watch list behavior unchanged Test coverage: - ConfigurationWatchListUtilTest validates no message logged when createCWL=false - Existing test suite passes: IncludeModelHandlerTest validates includes work correctly - New test cases cover various scenarios: default behavior, watchable/non-watchable protocols Fixes: qos-ch#1001 Signed-off-by: lukman48 <lukman_uki@yahoo.co.id>
Member
|
@lukman48 Please close this PR if you concur. |
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.
Summary
When a resource is included via
<include resource="file.xml"/>withoutscan="true", logback would log an unnecessary INFO message about ConfigurationWatchList not being initialized. This produces spurious warnings in logs even though everything works correctly.Root Cause
The
addToWatchList()method was logging a message whenever ConfigurationWatchList was null, regardless of whether file monitoring was actually enabled.Solution
Only log the message when
createCWL=true(which indicates that an attempt was made to create a watch list). WhencreateCWL=false(the default for<include>elements), silently return without logging, as file monitoring is not enabled and the classpath resource cannot be monitored anyway.Changes
ConfigurationWatchListUtil.addToWatchList()to conditionally log based on createCWL parameterConfigurationWatchListUtilTestwith 4 test cases covering:Benefits
✅ Cleaner logs: no spurious messages when
scan="false"(the default)✅ Expected behavior: resources from classpath without scan directive don't log warnings
✅ Maintains backward compatibility: existing watch list behavior unchanged
✅ All existing tests pass
Testing
ConfigurationWatchListUtilTest.java(4 test cases)IncludeModelHandlerTestvalidates includes work correctlylogback-coretest suite passesFixes #1001