Skip to content

[Misc] Use try-with-resources in TestDataParser (SonarQube java:S2093) - #402

Merged
vmassol merged 1 commit into
masterfrom
claude/peaceful-archimedes-dp9cxp
Aug 6, 2026
Merged

[Misc] Use try-with-resources in TestDataParser (SonarQube java:S2093)#402
vmassol merged 1 commit into
masterfrom
claude/peaceful-archimedes-dp9cxp

Conversation

@claude

@claude claude Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Jira URL

None — this is a [Misc] SonarQube cleanup commit.

Changes

Description

Fixes the one genuinely actionable java:S2093 issue in the repository: TestDataParser.parse opened a BufferedReader and closed it in a finally, which is exactly what try-with-resources is for.

  • The reader declaration moves into the try header, and the finally { reader.close(); } goes away.
  • The "Resources should always be encoded as UTF-8" comment moves with the declaration it explains.
  • Behaviour is unchanged except for the better case: if the body throws and close() throws, the close failure is now recorded as a suppressed exception instead of replacing the original one.

Clarifications

  • This is deliberately a small PR. The rest of 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 a public final class XxxUtil in the exported wikimodel packages removes the implicit public constructor and fails Revapi; S6126 — the wikimodel parser-test fixtures cannot be reproduced byte-for-byte by a text block).
  • The second open S2093 (AbstractInternalRenderingTest L160) is not fixed: its finally restores 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

mvn install -Plegacy,quality -pl xwiki-rendering-test,xwiki-rendering-integration-tests

xwiki-rendering-integration-tests is included on purpose: TestDataParser has almost no tests of its own, but that module drives every .test fixture file through it, so it is what actually exercises this change.

BUILD SUCCESSTests run: 1532, Failures: 0, Errors: 0, Skipped: 0.

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches: none — cleanup only, no behaviour change.

Related

Part of the same SonarQube sweep as xwiki/xwiki-commons#1878 and the sibling PR in xwiki-platform.


Generated by Claude Code

Co-Authored-By: Vincent Massol <vincent@massol.net>
@claude claude Bot added the llm-agent label Aug 6, 2026
@claude claude Bot assigned vmassol Aug 6, 2026
@claude claude Bot locked as resolved and limited conversation to collaborators Aug 6, 2026
@vmassol
vmassol merged commit 5de066d into master Aug 6, 2026
3 checks passed
@vmassol
vmassol deleted the claude/peaceful-archimedes-dp9cxp branch August 6, 2026 07:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant