Skip to content

Use access order for LRU type cache eviction - #143

Merged
cowtowncoder merged 4 commits into
FasterXML:mainfrom
Mr-KnightCLI:fix-lru-cache-access-order
Nov 25, 2026
Merged

cowtowncoder merged 4 commits into
FasterXML:mainfrom
Mr-KnightCLI:fix-lru-cache-access-order

Conversation

@Mr-KnightCLI

Copy link
Copy Markdown
Contributor

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.

@cowtowncoder cowtowncoder added the cla-needed PR looks good (although may also require code review), but CLA needed from submitter label Nov 25, 2026
@cowtowncoder

Copy link
Copy Markdown
Member

Hi @Mr-KnightCLI and thank you for the contribution! Looks good, will merge.

@cowtowncoder
cowtowncoder merged commit 3f76e94 into FasterXML:main Nov 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-needed PR looks good (although may also require code review), but CLA needed from submitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants