You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/04/12 20:41:58 UTC
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/
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;
}
}