This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit a49a867aa6087c59cc0308f8af72b0dcace0be6f Author: Guillaume Nodet <[email protected]> AuthorDate: Wed Mar 11 18:09:40 2026 +0100 Use LinkedHashSet for deterministic JAXB property ordering (#2945) Utils.getFields() and Utils.getGetters() use HashSet to collect bean properties from reflection, which produces non-deterministic iteration order. This causes serialized XML element order to vary between runs when @XmlType(propOrder) is not specified. Switch to LinkedHashSet to preserve insertion order (matching Class.getDeclaredFields/Methods order), ensuring deterministic serialization without requiring explicit propOrder on every bean. Co-authored-by: Claude Opus 4.6 <[email protected]> (cherry picked from commit a007b8e89a6253531798b3225d7827a167940290) --- rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java index b8a0d57dbf..020589da96 100644 --- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java +++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java @@ -27,7 +27,7 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; @@ -58,7 +58,7 @@ final class Utils { } private static Collection<Field> getFieldsInternal(Class<?> cls, XmlAccessType accessType) { - Set<Field> fields = new HashSet<>(); + Set<Field> fields = new LinkedHashSet<>(); Class<?> superClass = cls.getSuperclass(); if (superClass != null && !superClass.equals(Object.class) && !superClass.equals(Throwable.class)) { // process super class until java.lang.Object or java.lang.Throwable is not reached @@ -79,7 +79,7 @@ final class Utils { private static Collection<Method> getMethodsInternal(Class<?> cls, XmlAccessType accessType, boolean acceptSetters) { - Set<Method> methods = new HashSet<>(); + Set<Method> methods = new LinkedHashSet<>(); Class<?> superClass = cls.getSuperclass(); if (superClass != null && !superClass.equals(Object.class) && !superClass.equals(Throwable.class)) { // process super class until java.lang.Object or java.lang.Throwable is not reached
