You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2026/08/31 13:59:11 UTC

(poi-xmlbeans) branch trunk updated: Restore java_value fallbacks lost in the switch reordering (#101)

This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi-xmlbeans.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9de32942 Restore java_value fallbacks lost in the switch reordering (#101)
9de32942 is described below

commit 9de32942ddeb8338bbc42e8565f14fb9ed4dc717
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Mon Aug 31 14:59:05 2026 +0100

    Restore java_value fallbacks lost in the switch reordering (#101)
    
    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 <no...@anthropic.com>
---
 .../org/apache/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 27bb6509..8c50ed35 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 @@ public abstract class XmlObjectBase implements TypeStoreUser, Serializable, XmlO
 
                     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 @@ public abstract class XmlObjectBase implements TypeStoreUser, Serializable, XmlO
             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;
     }
 
     /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org