tbuffagni opened a new pull request, #427: URL: https://github.com/apache/commons-jcs/pull/427
## Problem Concurrent LRU evictors can select the same tail entry. `freeElement()` returns that entry even when `remove(key)` returns false, so `freeElements()` counts an unsuccessful removal as an eviction. Completed concurrent puts can consequently leave the cache above `MaxObjects`. A deterministic two-writer reproduction leaves two entries in a cache limited to one. The defect is present in current master, tested at a4f763cc3e04c8152d35aa2fda4a0a165eb55320. ## Changes - Count only successful removals; retry when another remover wins. - Skip and unlink stale list descriptors left by a remove between map publication and list publication. - Clear removed node links while holding the shard lock, preventing concurrent remove/move from observing old links after unlinking. - Add JUnit tests for concurrent puts and freeElements (1 and 16 shards), stale-tail progress, concurrent churn, and spool-failure retention. No public API changes or global writer lock. Spooling remains before removal and exceptions still propagate. This is a focused removal-accounting fix, not a redesign of callback deduplication or the remaining map/list publication protocol. ## Validation Windows, JDK 17.0.2: - Before: initial regression suite **6 tests, 5 assertion failures, 0 errors**; spool-failure retention already passed. - After: complete core suite **441 tests, 0 failures, 0 errors, 0 skipped**, including **8** new parameterized test cases. - Independent functional fixture with a real CompositeCacheManager: 8 writers / 65,536 puts / capacity 10,000 ends at **10,000** entries. Resident updates, synchronous update counts, expiry, callback delivery, clear/reuse and disposal checks pass. Core command (local Maven repository argument omitted): ```text mvn -o -B -nsu -Drat.skip=true -pl commons-jcs4-core clean test jar:jar ``` The full multi-module reactor and performance benchmarks were not run. RAT was skipped in this local core run. No throughput claim is made. Could you review this fix and the regression tests before I resume the performance comparison? -- 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]
