You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2021/09/02 18:28:58 UTC

[cxf] 02/02: [CXF-8590] Add synchronization to UnknownExtensibilityElement.getElement() call sites. The Element returned from getElement may not be thread safe, so we have to take precautions when accessing the Element. Also synchronize on the DescriptionInfo parameter in Wsdl11AttachmentPolicyProvider.getElementPolicy to avoid a race condition when registeredPolicy is not yet set.

This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 7400fd2119f71a49b0f3ced6ea4718441141a732
Author: Kim Johan Andersson <ki...@uddata.dk>
AuthorDate: Thu Sep 2 15:13:21 2021 +0200

    [CXF-8590]
    Add synchronization to UnknownExtensibilityElement.getElement() call sites.
    The Element returned from getElement may not be thread safe, so we have to take precautions when accessing the Element.
    Also synchronize on the DescriptionInfo parameter in Wsdl11AttachmentPolicyProvider.getElementPolicy to avoid a race condition when registeredPolicy is not yet set.
    
    (cherry picked from commit 9a4b855876e7d8ff68ca96760ab3d2ce84443a8e)
---
 .../cxf/ws/policy/attachment/reference/ReferenceResolverTest.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java
index c130203..dfd84ff 100644
--- a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java
+++ b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java
@@ -26,6 +26,7 @@ import java.util.List;
 import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.service.model.DescriptionInfo;
@@ -73,10 +74,12 @@ public class ReferenceResolverTest {
         extensions.add(extension);
         EasyMock.expect(di.getExtensors(UnknownExtensibilityElement.class)).andReturn(extensions);
         Element e = control.createMock(Element.class);
-        EasyMock.expect(extension.getElement()).andReturn(e).times(2);
         QName qn = new QName(Constants.URI_POLICY_NS,
                              Constants.ELEM_POLICY);
         EasyMock.expect(extension.getElementType()).andReturn(qn).anyTimes();
+        EasyMock.expect(extension.getElement()).andReturn(e).times(1);
+        Document ownerDocument = control.createMock(Document.class);
+        EasyMock.expect(e.getOwnerDocument()).andReturn(ownerDocument);
         EasyMock.expect(e.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
                                          PolicyConstants.WSU_ID_ATTR_NAME))
                         .andReturn("A");