Skip to content

LEGLINK-908: Avoid cache key collisions in Validation - #1840

Merged
johnbritton merged 3 commits into
devfrom
users/jbritton/LEGLINK-908
Aug 18, 2026
Merged

LEGLINK-908: Avoid cache key collisions in Validation#1840
johnbritton merged 3 commits into
devfrom
users/jbritton/LEGLINK-908

Conversation

@johnbritton

@johnbritton johnbritton commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🛠️ Description of Changes

Objects.hash returns a 32-bit int, so the key space is 2^32. Two different (codeSystem, code, display, valueSetUrl) tuples that hash to the same value share a cache entry, and the second lookup silently receives the first tuple's CodeValidationResult.

This PR replaces the hash with a delimiter-joined string key (codeSystem|code|display|valueSetUrl).

🧪 Testing Performed

Configured validation for remote terminology lookup and ran automated tests.

🧑‍🔬 Unit Testing

  • I have written or updated unit tests to cover my changes
  • Coverage: 100.0%

📓 Documentation Updated

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation and lookup caching to reliably distinguish different input combinations, including null, empty, and literal “null” values.
    • Ensured negative validation results are cached correctly while null results are not stored.
    • Improved cache consistency across supported caching backends.
  • Tests
    • Added coverage for cache key uniqueness, repeated lookups, backend storage, and worker-thread cache resolution.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 197d4a6b-a922-4ce8-b88e-3128eebaebf8

📥 Commits

Reviewing files that changed from the base of the PR and between e54a921 and 48c86c6.

📒 Files selected for processing (2)
  • Java/validation/src/main/java/com/lantanagroup/link/validation/providers/ValidationCacheService.java
  • Java/validation/src/test/java/com/lantanagroup/link/validation/providers/ValidationCacheServiceCachingTest.java

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

ValidationCacheService now builds structured cache keys for validation and lookup operations. Tests cover key uniqueness, null handling, backend storage, result caching, and threaded cache access.

Changes

Validation cache keys

Layer / File(s) Summary
Structured cache-key integration
Java/validation/src/main/java/com/lantanagroup/link/validation/providers/ValidationCacheService.java
Validation and lookup cache keys now use a shared builder with explicit null markers and length-prefixed non-null values.
Cache behavior validation
Java/validation/src/test/java/com/lantanagroup/link/validation/providers/ValidationCacheServiceCachingTest.java
Tests cover distinct keys, Caffeine and Redis storage, negative and null result caching, repeated lookups, threaded access, and Spring cache configuration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 48c86

The change makes validation cache keys specific to their input tuple and adds unit coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: seanmcilvenna

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing validation cache key collisions.
Description check ✅ Passed The description covers the changes, testing, unit tests, coverage, and documentation status.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch users/jbritton/LEGLINK-908

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@johnbritton
johnbritton merged commit 9348f69 into dev Aug 18, 2026
20 checks passed
@johnbritton
johnbritton deleted the users/jbritton/LEGLINK-908 branch August 18, 2026 14:04
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