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 3F52BF59E for ; Fri, 12 Apr 2013 18:42:20 +0000 (UTC) Received: (qmail 38954 invoked by uid 500); 12 Apr 2013 18:42:20 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 38892 invoked by uid 500); 12 Apr 2013 18:42:20 -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 38885 invoked by uid 99); 12 Apr 2013 18:42:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Apr 2013 18:42:20 +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; Fri, 12 Apr 2013 18:42:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 77F612388900; Fri, 12 Apr 2013 18:41:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1467404 - in /cxf/branches/2.6.x-fixes/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/ transports/http/src/main/java/org/apache/cxf/transport/http/ Date: Fri, 12 Apr 2013 18:41:58 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130412184158.77F612388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Fri Apr 12 18:41:57 2013 New Revision: 1467404 URL: http://svn.apache.org/r1467404 Log: Merged revisions 1467399 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes ........ r1467399 | dkulp | 2013-04-12 14:36:21 -0400 (Fri, 12 Apr 2013) | 10 lines Merged revisions 1467398 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1467398 | dkulp | 2013-04-12 14:28:46 -0400 (Fri, 12 Apr 2013) | 2 lines [CXF-4960] Fix a couple of startup race conditions ........ ........ Modified: cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java Modified: cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=1467404&r1=1467403&r2=1467404&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original) +++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Fri Apr 12 18:41:57 2013 @@ -831,72 +831,74 @@ public class SoapBindingFactory extends @Override public synchronized void addListener(Destination d, Endpoint e) { - MessageObserver mo = d.getMessageObserver(); - if (mo == null) { - super.addListener(d, e); - return; - } - - if (mo instanceof ChainInitiationObserver) { - ChainInitiationObserver cio = (ChainInitiationObserver) mo; - - Binding b = e.getBinding(); - Binding b2 = cio.getEndpoint().getBinding(); - if (b == b2) { - //re-registering the same endpoint? + synchronized (d) { + MessageObserver mo = d.getMessageObserver(); + if (mo == null) { + super.addListener(d, e); return; } - Object o = cio.getEndpoint().get("allow-multiplex-endpoint"); - if (o instanceof String) { - o = Boolean.parseBoolean((String)o); - } else if (o == null) { - o = Boolean.FALSE; - } - - if (b instanceof org.apache.cxf.binding.soap.SoapBinding - && b2 instanceof org.apache.cxf.binding.soap.SoapBinding - && ((org.apache.cxf.binding.soap.SoapBinding)b).getSoapVersion() - .equals(((org.apache.cxf.binding.soap.SoapBinding)b2).getSoapVersion()) - && Boolean.FALSE.equals(o)) { - - throw new RuntimeException("Soap " - + ((org.apache.cxf.binding.soap.SoapBinding)b) - .getSoapVersion().getVersion() - + " endpoint already registered on address " - + e.getEndpointInfo().getAddress()); - } - - MultipleEndpointObserver newMO = new MultipleEndpointObserver(getBus()) { - @Override - protected Message createMessage(Message message) { - return new SoapMessage(message); - } - }; - - newMO.getBindingInterceptors().add(new AttachmentInInterceptor()); - newMO.getBindingInterceptors().add(new StaxInInterceptor()); - - // This will not work if one of the endpoints disables message - // processing. But, if you've disabled message processing, you - // probably aren't going to use this feature. - - newMO.getBindingInterceptors().add(new ReadHeadersInterceptor(getBus(), (SoapVersion)null)); - newMO.getBindingInterceptors().add(new StartBodyInterceptor()); - newMO.getBindingInterceptors().add(new CheckFaultInterceptor()); - - // Add in a default selection interceptor - newMO.getRoutingInterceptors().add(new EndpointSelectionInterceptor()); - - newMO.getEndpoints().add(cio.getEndpoint()); - mo = newMO; - } - if (mo instanceof MultipleEndpointObserver) { - MultipleEndpointObserver meo = (MultipleEndpointObserver) mo; - meo.getEndpoints().add(e); + if (mo instanceof ChainInitiationObserver) { + ChainInitiationObserver cio = (ChainInitiationObserver) mo; + + Binding b = e.getBinding(); + Binding b2 = cio.getEndpoint().getBinding(); + if (b == b2) { + //re-registering the same endpoint? + return; + } + Object o = cio.getEndpoint().get("allow-multiplex-endpoint"); + if (o instanceof String) { + o = Boolean.parseBoolean((String)o); + } else if (o == null) { + o = Boolean.FALSE; + } + if (b instanceof org.apache.cxf.binding.soap.SoapBinding + && b2 instanceof org.apache.cxf.binding.soap.SoapBinding + && ((org.apache.cxf.binding.soap.SoapBinding)b).getSoapVersion() + .equals(((org.apache.cxf.binding.soap.SoapBinding)b2).getSoapVersion()) + && Boolean.FALSE.equals(o)) { + + throw new RuntimeException("Soap " + + ((org.apache.cxf.binding.soap.SoapBinding)b) + .getSoapVersion().getVersion() + + " endpoint already registered on address " + + e.getEndpointInfo().getAddress()); + } + + MultipleEndpointObserver newMO = new MultipleEndpointObserver(getBus()) { + @Override + protected Message createMessage(Message message) { + return new SoapMessage(message); + } + }; + + newMO.getBindingInterceptors().add(new AttachmentInInterceptor()); + newMO.getBindingInterceptors().add(new StaxInInterceptor()); + + // This will not work if one of the endpoints disables message + // processing. But, if you've disabled message processing, you + // probably aren't going to use this feature. + + newMO.getBindingInterceptors().add(new ReadHeadersInterceptor(getBus(), (SoapVersion)null)); + newMO.getBindingInterceptors().add(new StartBodyInterceptor()); + newMO.getBindingInterceptors().add(new CheckFaultInterceptor()); + + // Add in a default selection interceptor + newMO.getRoutingInterceptors().add(new EndpointSelectionInterceptor()); + + newMO.getEndpoints().add(cio.getEndpoint()); + + mo = newMO; + } + + if (mo instanceof MultipleEndpointObserver) { + MultipleEndpointObserver meo = (MultipleEndpointObserver) mo; + meo.getEndpoints().add(e); + } + + d.setMessageObserver(mo); } - - d.setMessageObserver(mo); } } Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java?rev=1467404&r1=1467403&r2=1467404&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java (original) +++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java Fri Apr 12 18:41:57 2013 @@ -42,20 +42,29 @@ public class DestinationRegistryImpl imp public DestinationRegistryImpl() { } - public void addDestination(AbstractHTTPDestination destination) { + public synchronized void addDestination(AbstractHTTPDestination destination) { String path = getTrimmedPath(destination.getEndpointInfo().getAddress()); - destinations.putIfAbsent(path, destination); + AbstractHTTPDestination dest = destinations.putIfAbsent(path, destination); + if (dest != null && dest != destination) { + throw new RuntimeException("Already a destination on " + path); + } try { - decodedDestinations.put(URLDecoder.decode(path, "ISO-8859-1"), destination); + String path2 = URLDecoder.decode(path, "ISO-8859-1"); + if (!path.equals(path2)) { + decodedDestinations.put(URLDecoder.decode(path, "ISO-8859-1"), destination); + } } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unsupported Encoding", e); } } - public void removeDestination(String path) { + public synchronized void removeDestination(String path) { destinations.remove(path); try { - decodedDestinations.remove(URLDecoder.decode(path, "ISO-8859-1")); + String path2 = URLDecoder.decode(path, "ISO-8859-1"); + if (!path.equals(path2)) { + decodedDestinations.remove(URLDecoder.decode(path, "ISO-8859-1")); + } } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unsupported Encoding", e); } Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java?rev=1467404&r1=1467403&r2=1467404&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java (original) +++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java Fri Apr 12 18:41:57 2013 @@ -266,30 +266,32 @@ public class HTTPTransportFactory if (endpointInfo == null) { throw new IllegalArgumentException("EndpointInfo cannot be null"); } - AbstractHTTPDestination d = registry.getDestinationForPath(endpointInfo.getAddress()); - if (d == null) { - HttpDestinationFactory jettyFactory = bus.getExtension(HttpDestinationFactory.class); - String addr = endpointInfo.getAddress(); - if (jettyFactory == null && addr != null && addr.startsWith("http")) { - String m = - new org.apache.cxf.common.i18n.Message("NO_HTTP_DESTINATION_FACTORY_FOUND" - , LOG).toString(); - LOG.log(Level.SEVERE, m); - throw new IOException(m); + synchronized (registry) { + AbstractHTTPDestination d = registry.getDestinationForPath(endpointInfo.getAddress()); + if (d == null) { + HttpDestinationFactory jettyFactory = bus.getExtension(HttpDestinationFactory.class); + String addr = endpointInfo.getAddress(); + if (jettyFactory == null && addr != null && addr.startsWith("http")) { + String m = + new org.apache.cxf.common.i18n.Message("NO_HTTP_DESTINATION_FACTORY_FOUND" + , LOG).toString(); + LOG.log(Level.SEVERE, m); + throw new IOException(m); + } + HttpDestinationFactory factory = null; + if (jettyFactory != null && (addr == null || addr.startsWith("http"))) { + factory = jettyFactory; + } else { + factory = new ServletDestinationFactory(); + } + + d = factory.createDestination(endpointInfo, getBus(), registry); + registry.addDestination(d); + configure(d); + d.finalizeConfig(); } - HttpDestinationFactory factory = null; - if (jettyFactory != null && (addr == null || addr.startsWith("http"))) { - factory = jettyFactory; - } else { - factory = new ServletDestinationFactory(); - } - - d = factory.createDestination(endpointInfo, getBus(), registry); - registry.addDestination(d); - configure(d); - d.finalizeConfig(); + return d; } - return d; } }