[Misc] Use try-with-resources in TestDataParser (SonarQube java:S2093) - #402
Merged
Conversation
Co-Authored-By: Vincent Massol <vincent@massol.net>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Jira URL
None — this is a
[Misc]SonarQube cleanup commit.Changes
Description
Fixes the one genuinely actionable
java:S2093issue in the repository:TestDataParser.parseopened aBufferedReaderand closed it in afinally, which is exactly what try-with-resources is for.tryheader, and thefinally { reader.close(); }goes away.close()throws, the close failure is now recorded as a suppressed exception instead of replacing the original one.Clarifications
xwiki-rendering's open SonarCloud backlog is not mechanical fodder: what remains is refactors (S127,S135,S3776), renames and API-shape changes (S1214,S2386,S1452,S2176), rules on the project denylist, and pools already analysed and rejected in earlier sweeps (S1118— adding a private constructor to apublic final class XxxUtilin the exportedwikimodelpackages removes the implicit public constructor and fails Revapi;S6126— thewikimodelparser-test fixtures cannot be reproduced byte-for-byte by a text block).S2093(AbstractInternalRenderingTestL160) is not fixed: itsfinallyrestores rendering-context state (MutableRenderingContext.pop()+executionContextManager.popContext()), it does not close a resource, so try-with-resources does not apply.Screenshots & Video
N/A — no UI change.
Executed Tests
xwiki-rendering-integration-testsis included on purpose:TestDataParserhas almost no tests of its own, but that module drives every.testfixture file through it, so it is what actually exercises this change.BUILD SUCCESS— Tests run: 1532, Failures: 0, Errors: 0, Skipped: 0.Expected merging strategy
Related
Part of the same SonarQube sweep as xwiki/xwiki-commons#1878 and the sibling PR in
xwiki-platform.Generated by Claude Code