cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject cxf git commit: [CXF-6404][CXF-6415] Lazily compute defaultAddress to avoid regression w/ WS-RM retransmission
Date Tue, 19 May 2015 21:48:51 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5bc8c0c41 -> dd1b3ebf5


[CXF-6404][CXF-6415] Lazily compute defaultAddress to avoid regression w/ WS-RM retransmission


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/dd1b3ebf
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/dd1b3ebf
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/dd1b3ebf

Branch: refs/heads/master
Commit: dd1b3ebf5b10651a2220a54a1f6e276d2197acf0
Parents: 5bc8c0c
Author: Alessio Soldano <asoldano@redhat.com>
Authored: Tue May 19 23:47:51 2015 +0200
Committer: Alessio Soldano <asoldano@redhat.com>
Committed: Tue May 19 23:47:51 2015 +0200

----------------------------------------------------------------------
 .../apache/cxf/transport/http/HTTPConduit.java  | 35 +++++++++++---------
 1 file changed, 19 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/dd1b3ebf/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index c5f6fdd..20c4aa2 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -208,7 +208,7 @@ public abstract class HTTPConduit
      * This field holds the "default" URI for this particular conduit, which
      * is created on demand.
      */
-    protected Address defaultAddress;
+    protected volatile Address defaultAddress;
     
     protected boolean fromEndpointReferenceType;
     
@@ -299,11 +299,6 @@ public abstract class HTTPConduit
         if (t != null) {
             fromEndpointReferenceType = true;
         }
-        try {
-            defaultAddress = createAddress();
-        } catch (URISyntaxException use) {
-            throw new IOException(use);
-        }
         proxyFactory = new ProxyFactory();
         cookies = new Cookies();
     }
@@ -679,6 +674,7 @@ public abstract class HTTPConduit
         String result = (String)message.get(Message.ENDPOINT_ADDRESS);
         String pathInfo = (String)message.get(Message.PATH_INFO);
         String queryString = (String)message.get(Message.QUERY_STRING);
+        setAndGetDefaultAddress();
         if (result == null) {
             if (pathInfo == null && queryString == null) {
                 message.put(Message.ENDPOINT_ADDRESS, defaultAddress.getString());
@@ -722,19 +718,26 @@ public abstract class HTTPConduit
      * @return the default target URL
      */
     protected URI getURI() throws URISyntaxException {
-        return defaultAddress.getURI();
+        return setAndGetDefaultAddress().getURI();
     }
 
-    private Address createAddress() throws URISyntaxException {
-        if (fromEndpointReferenceType && getTarget().getAddress().getValue() != null)
{
-            return new Address(this.getTarget().getAddress().getValue());
-        }
-        if (endpointInfo.getAddress() == null) {
-            throw new URISyntaxException("<null>", 
-                                         "Invalid address. Endpoint address cannot be null.",
-                                         0);
+    private Address setAndGetDefaultAddress() throws URISyntaxException {
+        if (defaultAddress == null) {
+            synchronized (this) {
+                if (defaultAddress == null) {
+                    if (fromEndpointReferenceType && getTarget().getAddress().getValue()
!= null) {
+                        defaultAddress = new Address(this.getTarget().getAddress().getValue());
+                    }
+                    if (endpointInfo.getAddress() == null) {
+                        throw new URISyntaxException("<null>", 
+                                                     "Invalid address. Endpoint address cannot
be null.",
+                                                     0);
+                    }
+                    defaultAddress = new Address(endpointInfo.getAddress());
+                }
+            }
         }
-        return new Address(endpointInfo.getAddress());
+        return defaultAddress;
     }
 
     /**


Mime
View raw message