Skip to content

Use access order for LRU type cache eviction - #143

Open
Mr-KnightCLI wants to merge 1 commit into
FasterXML:mainfrom
Mr-KnightCLI:fix-lru-cache-access-order
Open

Mr-KnightCLI wants to merge 1 commit into
FasterXML:mainfrom
Mr-KnightCLI:fix-lru-cache-access-order

Conversation

@Mr-KnightCLI

Copy link
Copy Markdown

LRUTypeCache.CacheMap currently uses LinkedHashMap's default insertion order. Although the cache is documented as retaining the most recently accessed types, reading an entry does not refresh its eviction position. With capacity two, inserting A and B, reading A, then inserting C incorrectly evicts A instead of B.

Enable access order in the backing map, retaining its default initial capacity and load factor. Reads and writes are already synchronized by LRUTypeCache. Add regressions for both a successful cache lookup and replacement of an existing value refreshing the eviction order. No wall-clock performance claim is made; this restores the intended cache retention policy.

Validation:

  • Compiled the focused cache test with javac --release 8, then executed it through Maven Surefire using the project's JUnit dependencies.
  • Original implementation: 7 cache tests run, 2 new regressions fail, 5 existing tests pass.
  • Updated implementation: all 7 cache tests pass via mvn -B -Dtest=TestResolvedTypeCache surefire:test.
  • git diff --cached --check: passed before committing.

Full Maven test-lifecycle attempts on Temurin 21.0.2 and Oracle JDK 22 stalled while compiling the broader test sources. The JDK 21 thread dump showed recursive javac Type.isErroneous calls. Those runs were stopped; the complete suite and verify were not completed locally. The focused test and updated class were compiled independently to avoid that compiler stall.

Prepared with OpenAI Codex assistance at the account owner's request for another tested open-source Java contribution. No independent human review is claimed.

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.

1 participant