Skip to content

fix: remove the artifact context thread-local after use - #290

Open
HuiJun wants to merge 1 commit into
developfrom
fix/artifacts-context-thread-local-leak
Open

HuiJun wants to merge 1 commit into
developfrom
fix/artifacts-context-thread-local-leak

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

DefaultArtifactService set the ArtifactsContext ThreadLocal to true around nodeService.createOrUpdate(...) and reset it to false in finally, which leaves a Boolean.FALSE entry on every pooled request thread that ever attached or detached an artifact. The finally blocks now call a new ArtifactsContext.clearArtifactContext(), which calls ThreadLocal.remove().

Fixes SonarCloud issue AaHWUyRI45Pg1SGp66kV (java:S5164, "Call "remove()" on "artifactContext"", ArtifactsContext.java:4).

Why it is safe

  • The only reader is ArtifactsContext.isArtifactContext(), which returns Boolean.TRUE.equals(artifactContext.get()): an absent value and false both read as false, so ArtifactsPersistenceNodeUpdateFilter behaves the same.
  • setArtifactContext(false) had exactly two callers, both replaced; setArtifactContext itself is unchanged.
  • ./gradlew :artifacts:build passes (the module has no unit tests; the artifacts Postman collection in CI exercises both paths).

Quality Assurance opened this PR for Jason
Implemented in session Get SonarCloud analysis landing for exec-mms
Review with Devin · Open in Devin Desktop


DefaultArtifactService left Boolean.FALSE in the ThreadLocal of pooled request
threads. Clearing it reads the same (isArtifactContext() is false for an absent
value) and releases the entry. Fixes Sonar java:S5164.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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.

1 participant