cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [cxf] 01/03: Add a getEmptyDocument method that returns a Document that can be uses as an Element factory. Avoids the synchronized System.getProperty calls in the Document constructor if that is not needed.
Date Thu, 19 Oct 2017 02:35:17 GMT
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 8c79c231b9e06901fbee317a5faec5b6807e5256
Author: Daniel Kulp <dkulp@apache.org>
AuthorDate: Wed Oct 18 11:03:17 2017 -0400

    Add a getEmptyDocument method that returns a Document that can be uses as an Element factory.
    Avoids the synchronized System.getProperty calls in the Document constructor if that is
not needed.
---
 .../main/java/org/apache/cxf/helpers/DOMUtils.java | 25 ++++++++++++++++++++++
 .../java/org/apache/cxf/interceptor/Fault.java     |  2 +-
 .../cxf/aegis/type/mtom/AbstractXOPType.java       |  2 +-
 .../apache/cxf/ws/addressing/soap/MAPCodec.java    |  2 +-
 .../java/org/apache/cxf/ws/mex/MEXEndpoint.java    |  2 +-
 .../cxf/ws/policy/PolicyAnnotationListener.java    |  2 +-
 .../cxf/ws/policy/ServiceModelPolicyUpdater.java   |  2 +-
 .../trust/claims/RoleClaimsCallbackHandler.java    |  2 +-
 .../security/wss4j/AbstractTokenInterceptor.java   |  2 +-
 .../transfer/dialect/fragment/FragmentDialect.java |  2 +-
 .../dialect/fragment/faults/FragmentFault.java     |  2 +-
 .../ws/transfer/manager/MemoryResourceManager.java |  2 +-
 .../transfer/integration/FragmentPutAddTest.java   | 10 ++++-----
 .../transfer/unit/MemoryResourceManagerTest.java   |  2 +-
 .../cxf/sts/operation/DefaultTokenWrapper.java     |  2 +-
 .../cxf/sts/operation/IssueEncryptedUnitTest.java  |  2 +-
 .../cxf/sts/operation/IssueJWTClaimsUnitTest.java  |  2 +-
 .../cxf/sts/operation/IssueJWTRealmUnitTest.java   |  2 +-
 .../apache/cxf/sts/operation/IssueJWTUnitTest.java |  2 +-
 .../cxf/sts/operation/IssueOnbehalfofUnitTest.java |  2 +-
 .../apache/cxf/sts/operation/IssueSCTUnitTest.java |  2 +-
 .../cxf/sts/operation/IssueSamlClaimsUnitTest.java |  4 ++--
 .../cxf/sts/operation/IssueSamlRealmUnitTest.java  |  2 +-
 .../cxf/sts/operation/IssueSamlUnitTest.java       | 10 ++++-----
 .../apache/cxf/sts/operation/IssueUnitTest.java    |  2 +-
 .../ValidateTokenTransformationUnitTest.java       |  4 ++--
 .../systest/sts/claims/ClaimsCallbackHandler.java  |  2 +-
 .../cxf/systest/ws/addressing/HeaderVerifier.java  |  2 +-
 28 files changed, 62 insertions(+), 37 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
index c9d000e..2f62bf6 100644
--- a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
@@ -62,6 +62,7 @@ public final class DOMUtils {
     private static final Map<ClassLoader, DocumentBuilder> DOCUMENT_BUILDERS
         = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilder>());
     private static final String XMLNAMESPACE = "xmlns";
+    private static volatile Document emptyDocument;
 
 
 
@@ -149,6 +150,30 @@ public final class DOMUtils {
             throw new RuntimeException(e);
         }
     }
+    
+    private static synchronized Document createEmptyDocument() {
+        if (emptyDocument == null) {
+            emptyDocument = createDocument();
+        }
+        return emptyDocument;
+    }
+    /**
+     * Returns a static Document that should always be "empty".  It's useful as a factory
for 
+     * for creating Elements and other nodes that will be traversed later and don't need
to 
+     * be attached into a document 
+     * @return
+     */
+    public static Document getEmptyDocument() {
+        Document doc = emptyDocument;
+        if (doc == null) {
+            doc = createEmptyDocument();
+        }
+        if (emptyDocument.getDocumentElement() != null) {
+            // doc = createEmptyDocument();
+            throw new IllegalStateException("Document should be empty");
+        }
+        return doc;
+    }
 
 
     /**
diff --git a/core/src/main/java/org/apache/cxf/interceptor/Fault.java b/core/src/main/java/org/apache/cxf/interceptor/Fault.java
index 435cd87..fcabade 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/Fault.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/Fault.java
@@ -166,7 +166,7 @@ public class Fault extends UncheckedException {
      */
     public Element getOrCreateDetail() {
         if (detail == null) {
-            detail = DOMUtils.createDocument().createElement("detail");
+            detail = DOMUtils.getEmptyDocument().createElement("detail");
         }
         return detail;
     }
diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
index 4a373ad..561a21e 100644
--- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
+++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
@@ -198,7 +198,7 @@ public abstract class AbstractXOPType extends AegisType {
     public void addToSchemaElement(XmlSchemaElement schemaElement) {
         if (expectedContentTypes != null) {
             Map<String, Node> extAttrMap = new HashMap<>();
-            Attr theAttr = DOMUtils.createDocument().createAttributeNS(XML_MIME_NS, "xmime");
+            Attr theAttr = DOMUtils.getEmptyDocument().createAttributeNS(XML_MIME_NS, "xmime");
             theAttr.setNodeValue(expectedContentTypes);
             extAttrMap.put("xmime", theAttr);
             schemaElement.addMetaInfo(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES, extAttrMap);
diff --git a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
index 2cf4f6e..4967467 100644
--- a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
+++ b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
@@ -912,7 +912,7 @@ public class MAPCodec extends AbstractSoapInterceptor {
         if (headerFactory == null) {
             headerFactory = new HeaderFactory() {
                 public Element getHeader(SoapVersion soapversion) {
-                    Document doc = DOMUtils.createDocument();
+                    Document doc = DOMUtils.getEmptyDocument();
                     return doc.createElementNS(soapversion.getHeader().getNamespaceURI(),
                             soapversion.getHeader().getLocalPart());
                 }
diff --git a/rt/ws/mex/src/main/java/org/apache/cxf/ws/mex/MEXEndpoint.java b/rt/ws/mex/src/main/java/org/apache/cxf/ws/mex/MEXEndpoint.java
index 2373c62..4d8b802 100644
--- a/rt/ws/mex/src/main/java/org/apache/cxf/ws/mex/MEXEndpoint.java
+++ b/rt/ws/mex/src/main/java/org/apache/cxf/ws/mex/MEXEndpoint.java
@@ -92,7 +92,7 @@ public class MEXEndpoint implements MetadataExchange {
                 org.apache.cxf.ws.mex.model._2004_09.MetadataReference ref
                     = new org.apache.cxf.ws.mex.model._2004_09.MetadataReference();
 
-                Element el = DOMUtils.createDocument().createElementNS(getAddressingNamespace(),
+                Element el = DOMUtils.getEmptyDocument().createElementNS(getAddressingNamespace(),
                                                                "wsa:Address");
                 el.setTextContent(s.getValue());
                 ref.getAny().add(el);
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
index 093c8d9..665cfde 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
@@ -404,7 +404,7 @@ public class PolicyAnnotationListener implements FactoryBeanListener {
             uri = "#" + uri;
         }
 
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element el = doc.createElementNS(ns, "wsp:" + Constants.ELEM_POLICY_REF);
         Attr att = doc.createAttributeNS(null, "URI");
         att.setValue(uri);
diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
index f238e3f..4c4a852 100644
--- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
+++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServiceModelPolicyUpdater.java
@@ -102,7 +102,7 @@ public class ServiceModelPolicyUpdater {
     }
 
     private void addPolicyRef(Extensible ext, Policy p) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element el = doc.createElementNS(p.getNamespace(), Constants.ELEM_POLICY_REF);
         el.setPrefix(Constants.ATTR_WSP);
         el.setAttribute(Constants.ATTR_URI, "#" + p.getId());
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/claims/RoleClaimsCallbackHandler.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/claims/RoleClaimsCallbackHandler.java
index fb6c56c..e315d6e 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/claims/RoleClaimsCallbackHandler.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/claims/RoleClaimsCallbackHandler.java
@@ -53,7 +53,7 @@ public class RoleClaimsCallbackHandler implements CallbackHandler {
      * Create a Claims Element for a "role"
      */
     private Element createClaims() {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element claimsElement =
             doc.createElementNS("http://docs.oasis-open.org/ws-sx/ws-trust/200512", "Claims");
         claimsElement.setAttributeNS(null, "Dialect", "http://schemas.xmlsoap.org/ws/2005/05/identity");
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractTokenInterceptor.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractTokenInterceptor.java
index 40c477e..e9f3d26 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractTokenInterceptor.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractTokenInterceptor.java
@@ -163,7 +163,7 @@ public abstract class AbstractTokenInterceptor extends AbstractSoapInterceptor
{
         if (!create) {
             return null;
         }
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element el = doc.createElementNS(WSS4JConstants.WSSE_NS, "wsse:Security");
         el.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsse", WSS4JConstants.WSSE_NS);
         SoapHeader sh = new SoapHeader(new QName(WSS4JConstants.WSSE_NS, "Security"), el);
diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/FragmentDialect.java
b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/FragmentDialect.java
index 6cc9184..2839f54 100644
--- a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/FragmentDialect.java
+++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/FragmentDialect.java
@@ -208,7 +208,7 @@ public class FragmentDialect implements Dialect {
      * @return
      */
     private JAXBElement<ValueType> generateGetResponseNode(Node node) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         ValueType resultValue = new ValueType();
         if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
             Element attrNodeEl = doc.createElementNS(
diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/faults/FragmentFault.java
b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/faults/FragmentFault.java
index 3777238..632fa12 100644
--- a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/faults/FragmentFault.java
+++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/dialect/fragment/faults/FragmentFault.java
@@ -34,7 +34,7 @@ public abstract class FragmentFault extends SoapFault {
     public FragmentFault(String reason, String detail, QName faultCode) {
         super(reason, faultCode);
         if (detail != null) {
-            Document doc = DOMUtils.createDocument();
+            Document doc = DOMUtils.getEmptyDocument();
             Element detailEl = doc.createElement("detail");
             detailEl.setTextContent(detail);
             setDetail(detailEl);
diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/manager/MemoryResourceManager.java
b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/manager/MemoryResourceManager.java
index 5c059dc..9aafa7f 100644
--- a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/manager/MemoryResourceManager.java
+++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/manager/MemoryResourceManager.java
@@ -120,7 +120,7 @@ public class MemoryResourceManager implements ResourceManager {
             storage.put(uuid, StaxUtils.toString(representationEl));
         }
 
-        Element uuidEl = DOMUtils.createDocument().createElementNS(REF_NAMESPACE, REF_LOCAL_NAME);
+        Element uuidEl = DOMUtils.getEmptyDocument().createElementNS(REF_NAMESPACE, REF_LOCAL_NAME);
         uuidEl.setTextContent(uuid);
 
         // Create referenceParameter
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
index 0ea1bbf..5587cff 100644
--- a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/FragmentPutAddTest.java
@@ -55,7 +55,7 @@ public class FragmentPutAddTest extends IntegrationBaseTest {
         expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
         expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
         expression.getContent().add("/");
-        Element addedElement = DOMUtils.createDocument().createElement("a");
+        Element addedElement = DOMUtils.getEmptyDocument().createElement("a");
         ValueType value = new ValueType();
         value.getContent().add(addedElement);
         fragment.setExpression(expression);
@@ -84,7 +84,7 @@ public class FragmentPutAddTest extends IntegrationBaseTest {
         expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
         expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
         expression.getContent().add("/");
-        Element addedElement = DOMUtils.createDocument().createElement("b");
+        Element addedElement = DOMUtils.getEmptyDocument().createElement("b");
         ValueType value = new ValueType();
         value.getContent().add(addedElement);
         fragment.setExpression(expression);
@@ -140,7 +140,7 @@ public class FragmentPutAddTest extends IntegrationBaseTest {
         expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
         expression.getContent().add("/a");
 
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element addedAttr = doc.createElementNS(
                 FragmentDialectConstants.FRAGMENT_2011_03_IRI,
                 FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME
@@ -181,7 +181,7 @@ public class FragmentPutAddTest extends IntegrationBaseTest {
         expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
         expression.getContent().add("/a");
 
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element addedAttr = doc.createElementNS(
                 FragmentDialectConstants.FRAGMENT_2011_03_IRI,
                 FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME
@@ -218,7 +218,7 @@ public class FragmentPutAddTest extends IntegrationBaseTest {
         expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
         expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
         expression.getContent().add("/a");
-        Element addedElement = DOMUtils.createDocument().createElement("c");
+        Element addedElement = DOMUtils.getEmptyDocument().createElement("c");
         ValueType value = new ValueType();
         value.getContent().add(addedElement);
         fragment.setExpression(expression);
diff --git a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/unit/MemoryResourceManagerTest.java
b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/unit/MemoryResourceManagerTest.java
index 30d7e0d..0a71446 100644
--- a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/unit/MemoryResourceManagerTest.java
+++ b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/unit/MemoryResourceManagerTest.java
@@ -107,7 +107,7 @@ public class MemoryResourceManagerTest {
     @Test(expected = UnknownResource.class)
     public void deleteUnknownReferenceParamsTest() {
         ReferenceParametersType refParams = new ReferenceParametersType();
-        Element uuid = DOMUtils.createDocument().createElementNS(
+        Element uuid = DOMUtils.getEmptyDocument().createElementNS(
                 MemoryResourceManager.REF_NAMESPACE, MemoryResourceManager.REF_LOCAL_NAME);
         uuid.setTextContent("123456");
         refParams.getAny().add(uuid);
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/DefaultTokenWrapper.java
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/DefaultTokenWrapper.java
index 4103082..0969dc6 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/DefaultTokenWrapper.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/DefaultTokenWrapper.java
@@ -37,7 +37,7 @@ public class DefaultTokenWrapper implements TokenWrapper {
      */
     public void wrapToken(Object token, RequestedSecurityTokenType requestedTokenType) {
         if (token instanceof String) {
-            Document doc = DOMUtils.newDocument();
+            Document doc = DOMUtils.getEmptyDocument();
             Element tokenWrapper = doc.createElementNS(null, "TokenWrapper");
             tokenWrapper.setTextContent((String)token);
             requestedTokenType.setAny(tokenWrapper);
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
index 636e197..a2ed021 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueEncryptedUnitTest.java
@@ -527,7 +527,7 @@ public class IssueEncryptedUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTClaimsUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTClaimsUnitTest.java
index df1c8b7..af4af68 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTClaimsUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTClaimsUnitTest.java
@@ -609,7 +609,7 @@ public class IssueJWTClaimsUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTRealmUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTRealmUnitTest.java
index b7e3567..709a977 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTRealmUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTRealmUnitTest.java
@@ -433,7 +433,7 @@ public class IssueJWTRealmUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTUnitTest.java
index 5c419b9..2536c55 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueJWTUnitTest.java
@@ -174,7 +174,7 @@ public class IssueJWTUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueOnbehalfofUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueOnbehalfofUnitTest.java
index 4811c7c..c433365 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueOnbehalfofUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueOnbehalfofUnitTest.java
@@ -1350,7 +1350,7 @@ public class IssueOnbehalfofUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
index 342956b..29b0f66 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSCTUnitTest.java
@@ -316,7 +316,7 @@ public class IssueSCTUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlClaimsUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlClaimsUnitTest.java
index 045ad1e..388b9ae 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlClaimsUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlClaimsUnitTest.java
@@ -792,7 +792,7 @@ public class IssueSamlClaimsUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
@@ -820,7 +820,7 @@ public class IssueSamlClaimsUnitTest extends org.junit.Assert {
      * Mock up a SecondaryParameters DOM Element containing some claims
      */
     private Element createSecondaryParameters() {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element secondary = doc.createElementNS(STSConstants.WST_NS_05_12, "SecondaryParameters");
         secondary.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns", STSConstants.WST_NS_05_12);
 
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlRealmUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlRealmUnitTest.java
index 30be179..4dc62f7 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlRealmUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlRealmUnitTest.java
@@ -514,7 +514,7 @@ public class IssueSamlRealmUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
index 1921924..56ddcd7 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueSamlUnitTest.java
@@ -1284,7 +1284,7 @@ public class IssueSamlUnitTest extends org.junit.Assert {
         String secondaryParticipant = "http://secondary.participant/";
 
         ParticipantType primary = new ParticipantType();
-        Document doc = DOMUtils.newDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         primary.setAny(createEndpointReference(doc, primaryParticipant));
 
         ParticipantType secondary = new ParticipantType();
@@ -1376,7 +1376,7 @@ public class IssueSamlUnitTest extends org.junit.Assert {
         String secondaryParticipant = "http://secondary.participant/";
 
         ParticipantType primary = new ParticipantType();
-        Document doc = DOMUtils.newDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         primary.setAny(createEndpointReference(doc, primaryParticipant));
 
         ParticipantType secondary = new ParticipantType();
@@ -1447,7 +1447,7 @@ public class IssueSamlUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         appliesTo.appendChild(createEndpointReference(doc, addressUrl));
@@ -1455,7 +1455,7 @@ public class IssueSamlUnitTest extends org.junit.Assert {
     }
 
     private Element createAppliesToURIElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
 
@@ -1484,7 +1484,7 @@ public class IssueSamlUnitTest extends org.junit.Assert {
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
         cryptoType.setAlias(alias);
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element x509Data = doc.createElementNS(WSS4JConstants.SIG_NS, "ds:X509Data");
         x509Data.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:ds", WSS4JConstants.SIG_NS);
         Element x509Cert = doc.createElementNS(WSS4JConstants.SIG_NS, "ds:X509Certificate");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueUnitTest.java
index 3ac6058..79bc9b0 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/IssueUnitTest.java
@@ -442,7 +442,7 @@ public class IssueUnitTest extends org.junit.Assert {
      * Mock up an AppliesTo element using the supplied address
      */
     private Element createAppliesToElement(String addressUrl) {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element appliesTo = doc.createElementNS(STSConstants.WSP_NS, "wsp:AppliesTo");
         appliesTo.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsp", STSConstants.WSP_NS);
         Element endpointRef = doc.createElementNS(STSConstants.WSA_NS_05, "wsa:EndpointReference");
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateTokenTransformationUnitTest.java
b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateTokenTransformationUnitTest.java
index 2bdf02c..40ebc21 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateTokenTransformationUnitTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateTokenTransformationUnitTest.java
@@ -780,7 +780,7 @@ public class ValidateTokenTransformationUnitTest extends org.junit.Assert
{
      * Mock up a DOM Element containing some claims
      */
     private JAXBElement<ClaimsType> createClaimsElement() {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
 
         Element claimType = createClaimsType(doc);
 
@@ -797,7 +797,7 @@ public class ValidateTokenTransformationUnitTest extends org.junit.Assert
{
      * Mock up a SecondaryParameters DOM Element containing some claims
      */
     private Element createClaimsElementInSecondaryParameters() {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element secondary = doc.createElementNS(STSConstants.WST_NS_05_12, "SecondaryParameters");
         secondary.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns", STSConstants.WST_NS_05_12);
 
diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/claims/ClaimsCallbackHandler.java
b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/claims/ClaimsCallbackHandler.java
index 766cc52..457e280 100644
--- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/claims/ClaimsCallbackHandler.java
+++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/claims/ClaimsCallbackHandler.java
@@ -54,7 +54,7 @@ public class ClaimsCallbackHandler implements CallbackHandler {
      * Create a Claims Element for a "role"
      */
     private Element createClaims() {
-        Document doc = DOMUtils.createDocument();
+        Document doc = DOMUtils.getEmptyDocument();
         Element claimsElement =
             doc.createElementNS("http://docs.oasis-open.org/ws-sx/ws-trust/200512", "Claims");
         claimsElement.setAttributeNS(null, "Dialect", "http://schemas.xmlsoap.org/ws/2005/05/identity");
diff --git a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
index 224266d..ace8efd 100644
--- a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
+++ b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
@@ -102,7 +102,7 @@ public class HeaderVerifier extends AbstractSoapInterceptor {
         try {
             // add piggybacked wsa:From header to partial response
             List<Header> header = message.getHeaders();
-            Document doc = DOMUtils.createDocument();
+            Document doc = DOMUtils.getEmptyDocument();
             SoapVersion ver = message.getVersion();
             Element hdr = doc.createElementNS(ver.getHeader().getNamespaceURI(),
                 ver.getHeader().getLocalPart());

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <commits@cxf.apache.org>.

Mime
View raw message