Skip to content

chore: #2058 Use unnamed patterns in commons exception handlers - #2059

Merged
lbroudoux merged 1 commit into
microcks:masterfrom
Heyy-Himanshuu:chore/2058-unnamed-patterns
Apr 30, 2026
Merged

lbroudoux merged 1 commit into
microcks:masterfrom
Heyy-Himanshuu:chore/2058-unnamed-patterns

Conversation

@Heyy-Himanshuu

Copy link
Copy Markdown
Contributor

Summary

Replace unused exception variables (nfe, t) with the Java 22+ unnamed pattern (_) across the commons/util-el module, addressing 6 of the maintainability findings raised by SonarCloud and aggregated under #2058.

Sites changed

NowELFunction#isInteger
RandomIntELFunction#evaluate (two catches)
RandomStringELFunction#evaluate
TemplateEngineTest#testContextlessTemplate
TemplateEngineTest#testPostmanNotationCompatibility
Each catch body either has only a comment or calls fail(...) with a hard-coded message — the exception variable was never read.

Notes

This rule (java:S???? for unnamed patterns) became applicable after the Java 25 upgrade in #2052 / #2057.
I did not include EvaluationContextTest's newInstance Sonar finding in this PR — it's a different rule with non-trivial replacement (Class.getDeclaredConstructor().newInstance() introduces additional checked exceptions). Happy to do it as a follow-up.

Replace unused exception variables with the unnamed pattern '_'
(JEP 456, available since Java 22) in catch blocks across the
commons/util-el module. Resolves Sonar findings flagged on the
1.14.x branch for the 1.15.0 milestone.

Affected sites:
- NowELFunction#isInteger
- RandomIntELFunction#evaluate (two catches)
- RandomStringELFunction#evaluate
- TemplateEngineTest#testContextlessTemplate
- TemplateEngineTest#testPostmanNotationCompatibility

Signed-off-by: Git-HimanshuRathi <[email protected]>
@github-actions

Copy link
Copy Markdown

👋 @Git-HimanshuRathi

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

@Heyy-Himanshuu

Copy link
Copy Markdown
Contributor Author

@lbroudoux

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pushing this. LGTM.

@lbroudoux lbroudoux added this to the 1.15.0 milestone Apr 30, 2026
@lbroudoux lbroudoux added kind/task java Pull requests that update Java code labels Apr 30, 2026
@lbroudoux
lbroudoux merged commit 1b88555 into microcks:master Apr 30, 2026
10 of 13 checks passed
@Heyy-Himanshuu
Heyy-Himanshuu deleted the chore/2058-unnamed-patterns branch May 1, 2026 09:34
lbroudoux pushed a commit that referenced this pull request May 4, 2026
…ger (#2061)

Sonar flagged two catch blocks in AsyncAPITestManager#runTest as
catching Throwable. Catching Throwable swallows JVM-fatal Errors
(OutOfMemoryError, StackOverflowError) that should be allowed to
propagate, so narrow both to Exception.

- Outer catch around invokeAny: rename t -> e and update log message
  and test-return reason to use the renamed variable.
- Finally-block catch around messageConsumptionTask.close(): the
  variable is unused (best-effort cleanup), so use the unnamed
  pattern '_' (JEP 456, available since Java 22), matching the
  convention introduced in #2059.

No behavioural change for the normal exception path; JVM Errors will
now propagate instead of being silently turned into FAILURE test
returns, which is the intended behaviour.

Signed-off-by: Git-HimanshuRathi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code kind/task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants