Skip to content

Fix #1001: Suppress spurious warning when including classpath config files without scan - #1037

Open
lukman48 wants to merge 1 commit into
qos-ch:masterfrom
lukman48:fix/1001-suppress-classpath-include-warning
Open

Fix #1001: Suppress spurious warning when including classpath config files without scan#1037
lukman48 wants to merge 1 commit into
qos-ch:masterfrom
lukman48:fix/1001-suppress-classpath-include-warning

Conversation

@lukman48

@lukman48 lukman48 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

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.

Changes

  • Modified ConfigurationWatchListUtil.addToWatchList() to conditionally log based on createCWL parameter
  • Added comprehensive test class ConfigurationWatchListUtilTest with 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

  • New test class: ConfigurationWatchListUtilTest.java (4 test cases)
  • Existing test suite passes: IncludeModelHandlerTest validates includes work correctly
  • Full logback-core test suite passes

Fixes #1001

…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>
@ceki

ceki commented Jul 25, 2026

Copy link
Copy Markdown
Member

@lukman48 IncludeModelHandler and ConfigurationWatchListUtil were reviewed and thoroughly modified in version 1.5.30. I think that this PE is no longer applicable.

Please close this PR if you concur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

including file from classpath produces unavoidable warning?

2 participants