Restore java_value fallbacks lost in the switch reordering - #101
Merged
Conversation
Reordering the switches in XmlObjectBase.java_value to put the default labels last silently changed what those defaults do when assertions are disabled. The outer default used to fall through to base.getStringValue(); after the reorder it fell out of the switch and returned null. The inner decimal-size default used to fall through to base.getBigDecimalValue(); after the reorder it fell out of the inner switch and dropped into the BTC_ANY_URI case, returning the string value instead. Give each default an explicit return matching the pre-reorder fallthrough target, and drop the now-unreachable trailing return null. Also fixes the stray indentation and duplicated comment the reorder left on the string cases. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Reordering the switches in
XmlObjectBase.java_valueto put thedefaultlabels last silently changed what those defaults do when assertions are disabled:default(unexpected nonprimitive type code) used to fall through tobase.getStringValue(); after the reorder it fell out of the switch and returnednull.default(invalid numeric bit count) used to fall through tobase.getBigDecimalValue(); after the reorder it fell out of the inner switch and dropped into theBTC_ANY_URIcase, returning the string value instead.Both paths are unreachable in normal operation (the assertions guard them in dev/test runs), but with
-dathe graceful fallbacks are part of observed behavior. This gives eachdefaultan explicitreturnmatching the pre-reorder fallthrough target, drops the now-unreachable trailingreturn null, and fixes the stray indentation and duplicated comment the reorder left on the string cases.Compiled and ran
xmlobject.schematypes.detailed.ListAndUnionTestslocally.🤖 Generated with Claude Code