This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit 5a4971f49e0e67386ef706e5d14287c48d80f791 Author: Robert Lazarski <[email protected]> AuthorDate: Sun Apr 19 21:39:33 2026 -1000 AXIS2-6074 Return null for empty enum values instead of throwing When an empty XML element is sent for an enum field (e.g., <eventType/>), the generated fromValue() method looked up the empty string in the enum table, got null, and threw IllegalArgumentException. This caused a cryptic SOAP fault ("unknown") with null HTTP status. Fix: in both bean and helpermode templates, allow null/empty values to return null from fromValue() instead of throwing. The bean template previously had this guard only for string property types — now it applies to all types. The helpermode template had no guard at all. This restores the Axis2 1.6 behavior where empty enum elements were handled gracefully. --- .../src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl | 3 ++- .../org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl b/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl index 25b891da3e..8a0efaed9d 100644 --- a/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl +++ b/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl @@ -1811,7 +1811,8 @@ </xsl:choose> // handle unexpected enumeration values properly - if (enumeration == null <xsl:if test="$propertyType='string'">&& !((value == null) || (value.equals("")))</xsl:if>) { + // AXIS2-6074: allow null/empty values for all types, not just string + if (enumeration == null && value != null && !value.toString().trim().isEmpty()) { <xsl:choose> <xsl:when test="$ignoreunexpected"> log.warn("Unexpected value " + value + " for enumeration <xsl:value-of select="$name"/>"); diff --git a/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl b/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl index 7703503ae8..761e958b54 100644 --- a/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl +++ b/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl @@ -253,7 +253,8 @@ </xsl:otherwise> </xsl:choose> - if (enumeration==null) throw new java.lang.IllegalArgumentException(); + // AXIS2-6074: return null for empty/null values instead of throwing + if (enumeration==null && value != null && !value.toString().trim().isEmpty()) throw new java.lang.IllegalArgumentException(); return enumeration; } public static <xsl:value-of select="$name"/> fromString(java.lang.String value)
