Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D69AE274 for ; Mon, 11 Feb 2013 20:47:37 +0000 (UTC) Received: (qmail 61674 invoked by uid 500); 11 Feb 2013 20:47:37 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 61623 invoked by uid 500); 11 Feb 2013 20:47:37 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 61615 invoked by uid 99); 11 Feb 2013 20:47:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 20:47:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 20:47:36 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2D2ED23889FA; Mon, 11 Feb 2013 20:47:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130211204717.2D2ED23889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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();