Skip to content

chore(QTDI-2901): S2095 Resource leaks#1236

Open
undx wants to merge 1 commit into
masterfrom
out/QTDI-2901-Resource-leaks
Open

chore(QTDI-2901): S2095 Resource leaks#1236
undx wants to merge 1 commit into
masterfrom
out/QTDI-2901-Resource-leaks

Conversation

@undx
Copy link
Copy Markdown
Member

@undx undx commented May 29, 2026

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

  • this PR has been written with the help of GitHub Copilot or another generative AI tool

Copy link
Copy Markdown
Contributor

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

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/BufferedOutputStream usages in try-with-resources across WebsiteBuilderMojo, VirtualDependenciesService, WriteIfDifferentStream, AsciidoctorExecutor, and SchemaConverter.
  • Refactor nested-jar stream handling in ComponentManager.toArchive so the input stream is reliably closed (and the previously-silent IOException is 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.

@undx undx requested a review from ozhelezniak-talend May 29, 2026 15:43
@sonar-rnd
Copy link
Copy Markdown

sonar-rnd Bot commented May 29, 2026

Failed Quality Gate failed

  • 0.00% Coverage on New Code (is less than 80.00%)
  • 2 New Issues (is greater than 0)

Project ID: org.talend.sdk.component:component-runtime

View in SonarQube

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