From 6fcde98a3df4b57ac59916d3f1f36585606f22e4 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 31 Aug 2026 14:44:26 +0100 Subject: [PATCH] Restore java_value fallbacks lost in the switch reordering 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 --- .../xmlbeans/impl/values/XmlObjectBase.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java b/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java index 27bb65099..8c50ed351 100644 --- a/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java +++ b/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java @@ -3081,9 +3081,10 @@ protected static Object java_value(XmlObject obj) { case SchemaType.SIZE_BIG_DECIMAL: return base.getBigDecimalValue(); + default: assert (false) : "invalid numeric bit count"; - // fallthrough + return base.getBigDecimalValue(); } } case SchemaType.BTC_ANY_URI: @@ -3101,19 +3102,18 @@ protected static Object java_value(XmlObject obj) { case SchemaType.BTC_G_DAY: case SchemaType.BTC_G_MONTH: return base.getCalendarValue(); - case SchemaType.BTC_NOTATION: + + // NB: for string enums we just do java.lang.String + // when in the context of unions. It's easier on users. + case SchemaType.BTC_NOTATION: case SchemaType.BTC_STRING: case SchemaType.BTC_ANY_SIMPLE: - // return base.getStringValue(); return base.getStringValue(); + default: assert (false) : "encountered nonprimitive type."; - // fallthrough - - // NB: for string enums we just do java.lang.String - // when in the context of unions. It's easier on users. + return base.getStringValue(); } - return null; } /**