Skip to content

fix: preserve in-flight secret lookups during LRU eviction - #204

Open
gibkim wants to merge 1 commit into
aws:v2from
gibkim:fix/retain-in-flight-secret-after-eviction
Open

gibkim wants to merge 1 commit into
aws:v2from
gibkim:fix/retain-in-flight-secret-after-eviction

Conversation

@gibkim

@gibkim gibkim commented Nov 21, 2026

Copy link
Copy Markdown

Description

Why is this change being made?

With a one-entry cache, inserting another secret between putIfAbsent and the subsequent lookup can evict the requested item. The lookup then returns null, causing getSecretString, getSecretBinary, or refreshNow to throw NullPointerException.

What is changing?

Retain the newly created item for the in-flight request. Reuse a competing same-key item while it remains cached. The public LRU API, capacity, and TTL are unchanged; evicted items are not reinserted.

AI-assisted implementation and tests using Codex/GPT-6; the author reviewed the diff.

Related Links


Testing

How was this tested?

  • Deterministic thread/latch tests cover all three entry points, insertion followed by eviction, a surviving same-key winner, and winner eviction: 6 NPE failures on the original code, all 9 passing with the fix.
  • Fixed-snapshot independent review: 33 related tests and 8 additional boundary cases passed; original-code negative control reproduced the 6 failures.

When testing locally, provide testing artifact(s):

mvn -B clean package on macOS, Temurin 21 / Java release 8:

Tests run: 59, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Checkstyle and SpotBugs passed. AWS SDK calls were mocked; native Linux CI has not run locally.


Reviewee Checklist

  • I have reviewed, tested and understand all changes
  • I have filled out the Description and Testing sections above
  • Build and Unit tests are passing
  • Unit test coverage check is passing
    If not, why: JaCoCo report generated locally; remote coverage pending.
  • I have ensured no sensitive information is leaking (i.e., no logging of sensitive fields, or otherwise)
  • I have added explanatory comments for complex logic, new classes/methods and new tests
  • I have updated README/documentation (if needed)
    If not, why: No public behavior or configuration documentation changes needed.
  • I have clearly called out breaking changes (if any)
    If not, why: No public API changes.

Reviewer Checklist

  • Reviewee checklist has been accurately filled out
  • Code changes align with stated purpose in description
  • Test coverage adequately validates the changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Keep the item used by an active lookup when another secret evicts its
cache mapping. Reuse a competing same-key item while it remains cached,
without changing the public LRU API, capacity, or TTL.

Cover all three entry points with deterministic concurrent eviction
and same-key insertion regressions.

Assisted-by: Codex/GPT-6
@gibkim
gibkim requested a review from a team as a code owner November 21, 2026 14:47
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.

2 participants