Skip to content

fix(QTDI-2567) prevent CacheMap eviction issue#1181

Open
thboileau wants to merge 3 commits intomasterfrom
tboileau/QTDI-2567_cacheMap_eviction_fix
Open

fix(QTDI-2567) prevent CacheMap eviction issue#1181
thboileau wants to merge 3 commits intomasterfrom
tboileau/QTDI-2567_cacheMap_eviction_fix

Conversation

@thboileau
Copy link
Copy Markdown
Contributor

@thboileau thboileau commented Mar 23, 2026

Requirements

  • Any code change adding any logic MUST be tested through a unit test executed with the default build
  • Any API addition MUST be done with a documentation update if relevant

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 treat maxSize <= 0 as “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.

@thboileau thboileau requested a review from ypiel-talend March 27, 2026 07:43
@thboileau thboileau force-pushed the tboileau/QTDI-2567_cacheMap_eviction_fix branch from c2cbd4b to 4dda348 Compare April 1, 2026 16:43
@thboileau thboileau force-pushed the tboileau/QTDI-2567_cacheMap_eviction_fix branch from 4dda348 to 5ddf512 Compare April 1, 2026 16:46
ypiel-talend
ypiel-talend previously approved these changes Apr 1, 2026
Copy link
Copy Markdown
Contributor

@ypiel-talend ypiel-talend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one simple question.

Copy link
Copy Markdown
Contributor

@ypiel-talend ypiel-talend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

3 participants