Skip to content

Fix switch case warning related unconditional break, return or throw statement.#17611

Open
anukalp2804 wants to merge 2 commits intoapache:masterfrom
anukalp2804:fix/switch_case_warning
Open

Fix switch case warning related unconditional break, return or throw statement.#17611
anukalp2804 wants to merge 2 commits intoapache:masterfrom
anukalp2804:fix/switch_case_warning

Conversation

@anukalp2804
Copy link
Copy Markdown
Contributor

@anukalp2804 anukalp2804 commented May 6, 2026

Summary

This PR resolves SonarCloud rule java:S128, switch cases should end with an unconditional break, return or throw statement. For that we have done some changes like :

  • Added break statements where execution could fall through to the next case
  • Removed unnecessary {} blocks from cases that already had unconditional return statements
  • Added {} blocks in a few places to make the case scope clearer for static analysis tools

Addressed : #17594
This PR has:

  • been self-reviewed.
  • been built locally with mvn spotless:apply.
  • been built locally with mvn clean package -DskipTests.
  • been built locally with mvn -pl iotdb-core -am test -DskipTests.

Resolves : https://sonarcloud.io/project/issues?impactSeverities=BLOCKER&issueStatuses=OPEN%2CCONFIRMED&id=apache_iotdb
End this switch case with an unconditional break, return or throw statement.

@HTHou HTHou requested a review from JackieTien97 May 7, 2026 01:24
@JackieTien97
Copy link
Copy Markdown
Contributor

@CRZbulabula @Caideyipi plz review related classes

Copy link
Copy Markdown
Contributor

@CRZbulabula CRZbulabula left a comment

Choose a reason for hiding this comment

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

LGTM

@HTHou
Copy link
Copy Markdown
Contributor

HTHou commented May 8, 2026

There are some tests failed, please check them.

@anukalp2804
Copy link
Copy Markdown
Contributor Author

I updated the code by removing the added "break" statements and using "// fall through" comments for the intentional fall-through cases.

These cases appear to be designed to continue execution into the subsequent cases, so adding "break" may be change the original behavior. The "// fall through" comments help clarify that the behavior is intentional and also resolve warnings.

Please review and let me know if any changes are needed from my side.

Thank you

@HTHou HTHou requested a review from JackieTien97 May 9, 2026 09:18
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.

5 participants