gnodet commented on PR #1165:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1165#issuecomment-7394844955

   _Claude Code on behalf of Guillaume Nodet_
   
   **Mtime-based hash caching can miss file changes**: The hash caching at line 
764 uses `sourceMtimes` to avoid recomputing hashes for unchanged files. 
However, filesystem mtime granularity (typically 1ms) can cause missed changes.
   
   **Scenario**: 
   1. User edits Foo.java at 1234.1ms → build at 1234.3ms stores mtime=1234ms, 
hash=ABC
   2. User edits Foo.java again at 1234.8ms → mtime still 1234ms due to 
truncation
   3. Next build reads mtime=1234ms, reuses hash=ABC → misses the second edit
   
   **Fix**: Either:
   - Always compute content hashes (slower but correct)
   - Use size+mtime as change token: `if (Files.size(sf) == cachedSize && 
Files.getLastModifiedTime(sf).toMillis() == cachedMtime)`
   - Document this limitation prominently and suggest users wait 1-2ms between 
edits in tight dev loops
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to