cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1132762 - in /cxf/trunk/rt: core/src/main/java/org/apache/cxf/wsdl11/ transports/local/src/main/java/org/apache/cxf/transport/local/ transports/local/src/test/java/org/apache/cxf/transport/local/
Date Mon, 06 Jun 2011 20:50:28 GMT
Author: dkulp
Date: Mon Jun  6 20:50:28 2011
New Revision: 1132762

URL: http://svn.apache.org/viewvc?rev=1132762&view=rev
Log:
LocalTransportFactory isn't thread safe

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
    cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=1132762&r1=1132761&r2=1132762&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Mon Jun
 6 20:50:28 2011
@@ -173,7 +173,7 @@ public class WSDLServiceBuilder {
         return buildServices(d, name, null, null);
     }
     public List<ServiceInfo> buildServices(Definition d, QName name, QName endpointName)
{
-        return buildServices(d, name, endpointName);
+        return buildServices(d, name, endpointName, null);
     }
 
     private List<ServiceInfo> buildServices(Definition d,

Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java?rev=1132762&r1=1132761&r2=1132762&view=diff
==============================================================================
--- cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
(original)
+++ cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
Mon Jun  6 20:50:28 2011
@@ -21,11 +21,12 @@ package org.apache.cxf.transport.local;
 
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.Executor;
 import java.util.logging.Logger;
 
@@ -45,6 +46,7 @@ import org.apache.cxf.transport.Destinat
 import org.apache.cxf.workqueue.WorkQueueManager;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.http.AddressType;
 
 @NoJSR250Annotations(unlessNull = { "bus" })
 public class LocalTransportFactory extends AbstractTransportFactory
@@ -62,12 +64,15 @@ public class LocalTransportFactory exten
 
     private static final Logger LOG = LogUtils.getL7dLogger(LocalTransportFactory.class);
     private static final Set<String> URI_PREFIXES = new HashSet<String>();
+    private static final String NULL_ADDRESS 
+        = LocalTransportFactory.class.getName() + ".nulladdress";
 
     static {
         URI_PREFIXES.add("local://");
     }
     
-    private Map<String, Destination> destinations = new HashMap<String, Destination>();
+    private ConcurrentMap<String, Destination> destinations 
+        = new ConcurrentHashMap<String, Destination>();
 
     private Set<String> messageFilterProperties;
     private Set<String> messageIncludeProperties;
@@ -103,10 +108,21 @@ public class LocalTransportFactory exten
     protected Destination getDestination(EndpointInfo ei,
                                          EndpointReferenceType reference)
         throws IOException {
-        Destination d = destinations.get(reference.getAddress().getValue());
+        Destination d = null;
+        String addr = reference.getAddress().getValue();
+        if (addr == null) {
+            AddressType tp = ei.getExtensor(AddressType.class);
+            if (tp != null) {
+                addr = tp.getLocation();
+            }
+        }
+        if (addr == null) {
+            addr = NULL_ADDRESS;
+        }
+        d = destinations.get(addr);
         if (d == null) {
             d = createDestination(ei, reference);
-            destinations.put(reference.getAddress().getValue(), d);
+            destinations.put(addr, d);
         }
         return d;
     }
@@ -117,7 +133,11 @@ public class LocalTransportFactory exten
     }
 
     void remove(LocalDestination destination) {
-        destinations.remove(destination);
+        for (Map.Entry<String, Destination> e : destinations.entrySet())  {
+            if (e.getValue() == destination) {
+                destinations.remove(e.getKey());
+            }
+        }
     }
     
     public Executor getExecutor() {

Modified: cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java?rev=1132762&r1=1132761&r2=1132762&view=diff
==============================================================================
--- cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java
(original)
+++ cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java
Mon Jun  6 20:50:28 2011
@@ -33,7 +33,6 @@ import org.apache.cxf.service.model.Endp
 import org.apache.cxf.transport.Conduit;
 
 import org.apache.cxf.transport.MessageObserver;
-import org.apache.cxf.wsdl.http.AddressType;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -54,9 +53,7 @@ public class LocalTransportFactoryTest e
         LocalTransportFactory factory = new LocalTransportFactory(bus);
         
         EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-        AddressType a = new AddressType();
-        a.setLocation("http://localhost/test");
-        ei.addExtensor(a);
+        ei.setAddress("http://localhost/test");
 
         LocalDestination d = (LocalDestination) factory.getDestination(ei);
         d.setMessageObserver(new EchoObserver());



Mime
View raw message