Add explicit default clauses to switches flagged by java/missing-case-in-switch - #791
Merged
vharseko merged 1 commit intoJul 31, 2026
Conversation
…-in-switch
All 38 flagged switch statements genuinely had no default clause. None of them
was a bug: for every enum value that is not listed, the correct behaviour today
is to do nothing and fall out of the switch, which is what the added clause
preserves. The change is additions only, so no behaviour is altered.
Each switch now ends with:
default:
// No action needed for the remaining values.
break;
so that adding a value to one of these enums no longer changes behaviour
silently.
In Uninstaller, BindRule, BindOperationBasis, LocalBackendAddOperation and
LocalBackendWorkflowElement the last case did not end with a break, which would
have made the new default clause reachable by fall-through. The effect is the
same, since the default clause only breaks, but an explicit break is added so no
implicit fall-through is left behind.
Five further switches in the same files are deliberately left alone. They are
exhaustive and were not flagged: the two switches over PasswordPolicyWarningType
in Utils and LDAPConnection cover both of its values, and the switches over
SubSystem in DirectoryServer and over HistKey in AttrHistoricalSingle and
AttrHistoricalMultiple are likewise complete.
maximthomas
approved these changes
Jul 30, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tier 3 of the warning-severity CodeQL triage (Tier 1 is #789, Tier 2 is #790). Closes all 38
java/missing-case-in-switchalerts.What was wrong
All 38 flagged switch statements genuinely had no
default:clause — that was verified for each one, not assumed. None of them is a bug today: for every enum value that is not listed, the correct behaviour is to do nothing and fall out of the switch, which is exactly what happens (falling through to areturn false, to a sharedreturn, or simply on to the next step).The risk the rule points at is the future one: adding a value to
ModificationType,SearchScope,Step,ServerStatusand friends would silently change behaviour at these 38 sites with nothing to flag it.The change
Every flagged switch now ends with:
The diff is additions only — no line is modified or removed, so no behaviour changes.
Explicit breaks
In
Uninstaller,BindRule,BindOperationBasis,LocalBackendAddOperationandLocalBackendWorkflowElementthe lastcasedid not end with abreak, which would have made the newdefaultclause reachable by fall-through. The effect is identical, since the clause only breaks, but an explicitbreak;is added rather than leaving implicit fall-through behind.Totals: 38
default:clauses, 38 comments, 43break;(38 in the new clauses plus these 5).Deliberately not touched
Five further switches in the same files have no
defaulteither, and are left alone because they are exhaustive — which is why CodeQL did not flag them:Utils:199,LDAPConnection:361PasswordPolicyWarningTypehas exactly two values, both coveredDirectoryServer:692SubSystemAttrHistoricalSingle:290,AttrHistoricalMultiple:575HistKeyAdding
defaultthere would be noise, so the change is scoped precisely to the 38 alerts.Verification
mvn -o compileforopendj-ldap-toolkitandopendj-server-legacy— passes, with no fall-through warnings.defaultlanded inside its switch body: of the switches in the touched files, 80 now have adefaultand 5 do not — exactly the exhaustive ones listed above.Note for reviewers
Three files are also touched by #790:
BrowserController.java,SearchOperationBasis.javaandUpgradeUtils.java. There is no overlap with #789. InUpgradeUtilsthe two edits are close together (try-with-resources around line 336 in #790, thedefaultaround line 360 here), and in all three files both branches add the same copyright line at the same place, so a small merge conflict is likely. Suggested order: #789 → #790 → this one.