Skip to content

Fix WatchService modification detection with fixed timestamps - #510

Open
YuqiGuo105 wants to merge 2 commits into
google:masterfrom
YuqiGuo105:fix/issue-483-watch-modifications
Open

YuqiGuo105 wants to merge 2 commits into
google:masterfrom
YuqiGuo105:fix/issue-483-watch-modifications

Conversation

@YuqiGuo105

@YuqiGuo105 YuqiGuo105 commented Aug 21, 2026

Copy link
Copy Markdown

Summary

  • track a monotonic modification version for each in-memory file
  • compare file identity and modification version in polling directory snapshots
  • add a regression test using a fixed FileTimeSource

Problem

PollingWatchService currently compares only lastModifiedTime values. If a file is written while the configured clock returns the same timestamp (for example, a fixed or low-resolution clock), the content changes but no ENTRY_MODIFY event is emitted.

The new snapshot state uses the file ID and its modification version. This detects writes without reading or hashing file contents, while also distinguishing a same-name replacement file.

Testing

  • mvn -pl jimfs -Dtest=PollingWatchServiceTest,FileTest test
  • mvn test (5,906 tests passed, 1 skipped)

Fixes #483

@YuqiGuo105
YuqiGuo105 marked this pull request as ready for review August 21, 2026 17:52
@chaoren chaoren added type=enhancement Make an existing feature better P3 labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 type=enhancement Make an existing feature better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WatchService(PollingWatchService): Only uses timestamp to determine if a file has "changed" ignores content.

2 participants