chore(QTDI-2901): S2095 Resource leaks#1236
Open
undx wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses SonarQube S2095 (resource leak) findings across several modules by wrapping Files.list, Files.lines, JsonReader, and stream-wrapped JarOutputStream usages in try-with-resources, restructuring nested-stream cleanup in ComponentManager.toArchive, and adding S2095/resource suppressions for cases where ownership is intentionally transferred elsewhere (Spark monitor thread, Container lifecycle owned by ContainerManager).
Changes:
- Wrap
Files.list/Files.lines/JsonReader/BufferedOutputStreamusages in try-with-resources acrossWebsiteBuilderMojo,VirtualDependenciesService,WriteIfDifferentStream,AsciidoctorExecutor, andSchemaConverter. - Refactor nested-jar stream handling in
ComponentManager.toArchiveso the input stream is reliably closed (and the previously-silentIOExceptionis now rethrown). - Add documented
@SuppressWarnings({"resource", "java:S2095"})to call sites whose closeable lifecycle is owned by another component (ContainerManager, Spark cleanup tasks).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| talend-component-maven-plugin/.../WebsiteBuilderMojo.java | Close Files.list streams in directory cleanup and template enumeration. |
| documentation/.../WriteIfDifferentStream.java | Close Files.lines stream while reading existing destination for diff. |
| component-tools/.../AsciidoctorExecutor.java | Close Files.lines stream while collecting .adoc lines. |
| component-server-parent/.../VirtualDependenciesService.java | Add try-with-resources for BufferedOutputStream+JarOutputStream and for Files.list(familyFolder). |
| component-runtime-testing-spark/.../BaseSpark.java | Wrap FileOutputStream+JarOutputStream together; suppress S2095 for SparkProcessMonitor whose lifecycle is managed by cleanup tasks. |
| component-runtime-manager/.../SchemaConverter.java | Close JsonReader created from the input string. |
| component-runtime-manager/.../ComponentManager.java | Suppress S2095 on container-builder calls (ownership transferred to ContainerManager); restructure toArchive nested-stream handling to always close nestedStream on failure and rethrow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.

https://qlik-dev.atlassian.net/browse/QTDI-2901
AI generated code
https://internal.qlik.dev/general/ways-of-working/code-reviews/#guidelines-for-ai-generated-code