Skip to content

fix: close IFile.getContents() streams in Toc/Contexts generators#1393

Merged
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:fix/toc-contexts-getcontents-leaks
Jun 1, 2026
Merged

fix: close IFile.getContents() streams in Toc/Contexts generators#1393
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:fix/toc-contexts-getcontents-leaks

Conversation

@joaodinissf

Copy link
Copy Markdown
Collaborator

CheckTocGenerator.loadTocModel and CheckContextsGenerator.updateContextsFile/removeContexts passed file.getContents() straight to CoreUtility.getTextDocument and model.load, neither of which closes a caller-supplied stream — leaking an InputStream per call.

Each is now wrapped in try-with-resources. Because these methods only declare throws CoreException, the close()-time IOException is caught and re-wrapped in a CoreException using the module's existing pattern (new Status(Status.ERROR, Activator.getPluginId(), …), as in DeployJob).

Found by a repo-wide inconsistency sweep. (Split out from #1390; this one needed the extra IOException handling.)

🤖 Generated with Claude Code

CheckTocGenerator.loadTocModel and CheckContextsGenerator.update/removeContexts
passed file.getContents() straight to CoreUtility.getTextDocument and
model.load, which do not close caller-supplied streams. Wrap each in
try-with-resources; since these methods only declare CoreException, the
close()-time IOException is caught and wrapped in a CoreException (same pattern
as DeployJob in this module).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joaodinissf joaodinissf marked this pull request as ready for review May 30, 2026 16:30
@joaodinissf joaodinissf enabled auto-merge (rebase) May 30, 2026 16:35
@joaodinissf joaodinissf merged commit d07782b into dsldevkit:master Jun 1, 2026
4 checks passed
@joaodinissf joaodinissf deleted the fix/toc-contexts-getcontents-leaks branch June 1, 2026 07:18
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