jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
changeset 43126 26c4004e8cc0
parent 33547 e4c76ac38b12
child 43852 93a527059d8a
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java	Wed Jul 05 22:40:29 2017 +0200
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java	Tue Jan 10 22:15:54 2017 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,8 +127,11 @@
     }
 
     public SOAPElement addChildElement(String localName) throws SOAPException {
-        return (SOAPElement) addChildElement(
-            NameImpl.createFromUnqualifiedName(localName));
+        String nsUri = getNamespaceURI("");
+        Name name = (nsUri == null || nsUri.isEmpty())
+                ?  NameImpl.createFromUnqualifiedName(localName)
+                :  NameImpl.createFromQualifiedName(localName, nsUri);
+        return addChildElement(name);
     }
 
     public SOAPElement addChildElement(String localName, String prefix)
@@ -372,13 +375,13 @@
     protected SOAPElement addElement(Name name) throws SOAPException {
         SOAPElement newElement = createElement(name);
         addNode(newElement);
-        return circumventBug5034339(newElement);
+        return newElement;
     }
 
     protected SOAPElement addElement(QName name) throws SOAPException {
         SOAPElement newElement = createElement(name);
         addNode(newElement);
-        return circumventBug5034339(newElement);
+        return newElement;
     }
 
     protected SOAPElement createElement(Name name) {
@@ -1226,26 +1229,6 @@
         return !"".equals(name.getNamespaceURI());
     }
 
-    protected SOAPElement circumventBug5034339(SOAPElement element) {
-
-        Name elementName = element.getElementName();
-        if (!isNamespaceQualified(elementName)) {
-            String prefix = elementName.getPrefix();
-            String defaultNamespace = getNamespaceURI(prefix);
-            if (defaultNamespace != null) {
-                Name newElementName =
-                    NameImpl.create(
-                        elementName.getLocalName(),
-                        elementName.getPrefix(),
-                        defaultNamespace);
-                SOAPElement newElement = createElement(newElementName);
-                replaceChild(newElement, element);
-                return newElement;
-            }
-        }
-        return element;
-    }
-
     //TODO: This is a temporary SAAJ workaround for optimizing XWS
     // should be removed once the corresponding JAXP bug is fixed
     // It appears the bug will be fixed in JAXP 1.4 (not by Appserver 9 timeframe)