fix(QTDI-2567) prevent CacheMap eviction issue#1181
Open
fix(QTDI-2567) prevent CacheMap eviction issue#1181
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a runtime exception in MapCache.evictIfNeeded() when trimming concurrent caches used by component-server resources, and adds unit tests to validate eviction behavior.
Changes:
- Fix eviction logic to remove entries safely via iterator
next()+remove(), and treatmaxSize <= 0as “clear cache”. - Add JUnit 5 parameterized tests covering emptying, trimming, and no-op scenarios for
evictIfNeeded(). - Minor comment typo fixes in
MapCache.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/lang/MapCache.java | Fixes eviction implementation to avoid iterator misuse exceptions when enforcing max cache size. |
| component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/lang/MapCacheTest.java | Adds unit tests for eviction behavior (empty, trimmed, unchanged). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ver-parent/component-server/src/main/java/org/talend/sdk/component/server/lang/MapCache.java
Show resolved
Hide resolved
...parent/component-server/src/test/java/org/talend/sdk/component/server/lang/MapCacheTest.java
Show resolved
Hide resolved
...parent/component-server/src/test/java/org/talend/sdk/component/server/lang/MapCacheTest.java
Show resolved
Hide resolved
c2cbd4b to
4dda348
Compare
4dda348 to
5ddf512
Compare
ypiel-talend
reviewed
Apr 1, 2026
ypiel-talend
previously approved these changes
Apr 1, 2026
Contributor
ypiel-talend
left a comment
There was a problem hiding this comment.
Just one simple question.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements
Why this PR is needed?
Component-server maintains two maps with a size limit. The code that should take care of this limit throws an exception when called
What does this PR adds (design/code thoughts)?
It prevents the exception, and a test case is also provided.