Skip to content

[ISSUE #11608] fix(srvutil): watch configured files that are created after startup - #11609

Merged
ShannonDing merged 2 commits into
apache:developfrom
zjt0926:fix/file-watch-created-after-start
Nov 26, 2026
Merged

ShannonDing merged 2 commits into
apache:developfrom
zjt0926:fix/file-watch-created-after-start

Conversation

@zjt0926

@zjt0926 zjt0926 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #11608

Brief Description

FileWatchService only registered watch targets that already existed when the service was constructed. run0() re-hashes only the paths stored in currentHash, so a configured file that did not exist at startup was never watched: when it was created later (for example a TLS certificate provisioned or mounted after the process started), Listener.onChanged was never invoked and the dynamic TLS certificate reload never happened.

md5Digest() already returns an empty hash for a missing file and reuses the previous hash for a deleted file, so the exists() check in the constructor is not required. All non-empty configured paths are now registered, and a later-created file is detected on the next watch round. Behaviour for deleted files is unchanged: the deletion itself does not produce an event, and a subsequent re-creation with different content does.

How Did You Test This Change?

Added FileWatchServiceTest#watchSingleFile_CreatedAfterStart, which constructs the service with a non-existent path, creates the file after the service starts and asserts that the listener is called.

  • mvn -pl srvutil -am "-Dtest=FileWatchServiceTest" test - passed (Tests run: 6, Failures: 0, Errors: 0)
  • mvn -pl srvutil validate (project checkstyle) - 0 violations

@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.69%. Comparing base (74c2a8e) to head (ab2eea6).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11609      +/-   ##
=============================================
+ Coverage      50.47%   50.69%   +0.22%     
- Complexity     14711    14784      +73     
=============================================
  Files           1391     1391              
  Lines         103541   103571      +30     
  Branches       13575    13575              
=============================================
+ Hits           52261    52509     +248     
+ Misses         45042    44807     -235     
- Partials        6238     6255      +17     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ShannonDing
ShannonDing merged commit 79e29dd into apache:develop Nov 26, 2026
10 checks passed
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.

[Bug] FileWatchService ignores configured files that do not exist at startup

3 participants