Author: dkulp Date: Tue Feb 19 20:51:47 2013 New Revision: 1447912 URL: http://svn.apache.org/r1447912 Log: Merged revisions 1446667 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
........ r1446667 | dkulp | 2013-02-15 11:14:03 -0500 (Fri, 15 Feb 2013) | 10 lines Merged revisions 1446658 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1446658 | dkulp | 2013-02-15 11:05:30 -0500 (Fri, 15 Feb 2013) | 2 lines Check if a policy is already registered to avoid a bunch of duplicates. ........ ........ Modified: cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java Modified: cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?rev=1447912&r1=1447911&r2=1447912&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java (original) +++ cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java Tue Feb 19 20:51:47 2013 @@ -185,18 +185,20 @@ public class Wsdl11AttachmentPolicyProvi if (Constants.isPolicyElement(e.getElementType()) && !StringUtils.isEmpty(uri)) { - try { - Policy policy = builder.getPolicy(e.getElement()); - String fragement = "#" + uri; - registry.register(fragement, policy); - if (di.getBaseURI() == null) { - registry.register(Integer.toString(di.hashCode()) + fragement, policy); - } else { - registry.register(di.getBaseURI() + fragement, policy); + + String id = (di.getBaseURI() == null ? Integer.toString(di.hashCode()) : di.getBaseURI()) + + "#" + uri; + Policy policy = registry.lookup(id); + if (policy == null) { + try { + policy = builder.getPolicy(e.getElement()); + String fragement = "#" + uri; + registry.register(fragement, policy); + registry.register(id, policy); + } catch (Exception policyEx) { + //ignore the policy can not be built + LOG.warning("Failed to build the policy '" + uri + "':" + policyEx.getMessage()); } - } catch (Exception policyEx) { - //ignore the policy can not be built - LOG.warning("Failed to build the policy '" + uri + "':" + policyEx.getMessage()); } } }
