From 0f831ec6a589379a8ed3912b88cc8fce264696cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 20 Jul 2024 15:38:47 +0200 Subject: [PATCH] Fallback to node name if not local name is available Fix https://github.com/eclipse-ee4j/jaxb-ri/issues/1807 --- .../org/glassfish/jaxb/runtime/v2/runtime/BinderImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BinderImpl.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BinderImpl.java index b3948632d..9ae096d1d 100644 --- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BinderImpl.java +++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BinderImpl.java @@ -20,6 +20,8 @@ import org.w3c.dom.Node; import org.xml.sax.SAXException; +import java.util.Objects; + import javax.xml.namespace.QName; import javax.xml.validation.Schema; @@ -178,7 +180,7 @@ public XmlNode updateXML(Object jaxbObject, XmlNode xmlNode) throws JAXBExceptio // the marshalling successful. JaxBeanInfo bi = context.getBeanInfo(jaxbObject, true); if(!bi.isElement()) - jaxbObject = new JAXBElement(new QName(e.getNamespaceURI(),e.getLocalName()),bi.jaxbType,jaxbObject); + jaxbObject = new JAXBElement(new QName(e.getNamespaceURI(),Objects.requireNonNullElse(e.getLocalName(), e.getNodeName()),bi.jaxbType,jaxbObject); getMarshaller().marshal(jaxbObject,p);