cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1444957 - in /cxf/trunk/rt/ws/policy/src: main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
Date Mon, 11 Feb 2013 20:47:17 GMT
Author: dkulp
Date: Mon Feb 11 20:47:16 2013
New Revision: 1444957

URL: http://svn.apache.org/r1444957
Log:
Returning null matches the other providers and can avoid some expensive merges

Modified:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java?rev=1444957&r1=1444956&r2=1444957&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
(original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
Mon Feb 11 20:47:16 2013
@@ -81,9 +81,12 @@ public class ExternalAttachmentProvider 
 
     public Policy getEffectivePolicy(BindingFaultInfo bfi) {
         readDocument();
-        Policy p = new Policy();
+        Policy p = null;
         for (PolicyAttachment pa : attachments) {
             if (pa.appliesTo(bfi)) {
+                if (p == null) {
+                    p = new Policy();
+                }
                 p = p.merge(pa.getPolicy());
             }
         }
@@ -93,21 +96,26 @@ public class ExternalAttachmentProvider 
 
     public Policy getEffectivePolicy(BindingMessageInfo bmi) {
         readDocument();
-        Policy p = new Policy();
+        Policy p = null;
         for (PolicyAttachment pa : attachments) {
             if (pa.appliesTo(bmi)) {
+                if (p == null) {
+                    p = new Policy();
+                }
                 p = p.merge(pa.getPolicy());
             }
         }
-                
         return p;
     }
 
     public Policy getEffectivePolicy(BindingOperationInfo boi) {
         readDocument();
-        Policy p = new Policy();
+        Policy p = null;
         for (PolicyAttachment pa : attachments) {
             if (pa.appliesTo(boi)) {
+                if (p == null) {
+                    p = new Policy();
+                }
                 p = p.merge(pa.getPolicy());
             }
         }
@@ -117,9 +125,12 @@ public class ExternalAttachmentProvider 
 
     public Policy getEffectivePolicy(EndpointInfo ei) {
         readDocument();
-        Policy p = new Policy();
+        Policy p = null;
         for (PolicyAttachment pa : attachments) {
             if (pa.appliesTo(ei)) {
+                if (p == null) {
+                    p = new Policy();
+                }
                 p = p.merge(pa.getPolicy());
             }
         }
@@ -129,9 +140,12 @@ public class ExternalAttachmentProvider 
 
     public Policy getEffectivePolicy(ServiceInfo si) {
         readDocument();
-        Policy p = new Policy();
+        Policy p = null;
         for (PolicyAttachment pa : attachments) {
             if (pa.appliesTo(si)) {
+                if (p == null) {
+                    p = new Policy();
+                }
                 p = p.merge(pa.getPolicy());
             }
         }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java?rev=1444957&r1=1444956&r2=1444957&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
(original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
Mon Feb 11 20:47:16 2013
@@ -84,7 +84,7 @@ public class ExternalAttachmentProviderT
         BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
         setUpAttachment(bfi, false, eap);
         control.replay();
-        assertTrue(eap.getEffectivePolicy(bfi).isEmpty());
+        assertNull(eap.getEffectivePolicy(bfi));
         control.verify();
         
         control.reset();
@@ -100,7 +100,7 @@ public class ExternalAttachmentProviderT
         BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class);
         setUpAttachment(bmi, false, eap);
         control.replay();
-        assertTrue(eap.getEffectivePolicy(bmi).isEmpty());
+        assertNull(eap.getEffectivePolicy(bmi));
         control.verify();
         
         control.reset();
@@ -116,7 +116,7 @@ public class ExternalAttachmentProviderT
         ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
         setUpAttachment(boi, false, eap);
         control.replay();
-        assertTrue(eap.getEffectivePolicy(boi).isEmpty());
+        assertNull(eap.getEffectivePolicy(boi));
         control.verify();
         
         control.reset();
@@ -132,7 +132,7 @@ public class ExternalAttachmentProviderT
         EndpointInfo ei = control.createMock(EndpointInfo.class);
         setUpAttachment(ei, false, eap);
         control.replay();
-        assertTrue(eap.getEffectivePolicy(ei).isEmpty());
+        assertNull(eap.getEffectivePolicy(ei));
         control.verify();
         
         control.reset();
@@ -148,7 +148,7 @@ public class ExternalAttachmentProviderT
         ServiceInfo si = control.createMock(ServiceInfo.class);
         setUpAttachment(si, false, eap);
         control.replay();
-        assertTrue(eap.getEffectivePolicy(si).isEmpty());
+        assertNull(eap.getEffectivePolicy(si));
         control.verify();
         
         control.reset();



Mime
View raw message