Skip to content

Restore java_value fallbacks lost in the switch reordering - #101

Merged
pjfanning merged 1 commit into
apache:trunkfrom
pjfanning:java-value-default-fallback
Aug 31, 2026
Merged

Restore java_value fallbacks lost in the switch reordering#101
pjfanning merged 1 commit into
apache:trunkfrom
pjfanning:java-value-default-fallback

Conversation

@pjfanning

Copy link
Copy Markdown
Member

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 (unexpected nonprimitive type code) used to fall through to base.getStringValue(); after the reorder it fell out of the switch and returned null.
  • The inner decimal-size default (invalid numeric bit count) 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.

Both paths are unreachable in normal operation (the assertions guard them in dev/test runs), but with -da the graceful fallbacks are part of observed behavior. This gives each default an explicit return matching the pre-reorder fallthrough target, drops the now-unreachable trailing return null, and fixes the stray indentation and duplicated comment the reorder left on the string cases.

Compiled and ran xmlobject.schematypes.detailed.ListAndUnionTests locally.

🤖 Generated with Claude Code

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>
@pjfanning
pjfanning merged commit 9de3294 into apache:trunk Aug 31, 2026
2 checks passed
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.

1 participant