Repository: cxf Updated Branches: refs/heads/3.0.x-fixes ae6ce7289 -> a9e2e30a5
[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/997b4e13 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/997b4e13 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/997b4e13 Branch: refs/heads/3.0.x-fixes Commit: 997b4e13a4ca2fbac7b0c33713c78335fee1fe37 Parents: ae6ce72 Author: Alessio Soldano <[email protected]> Authored: Tue May 19 23:47:51 2015 +0200 Committer: Alessio Soldano <[email protected]> Committed: Wed May 20 09:48:23 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/997b4e13/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 57c6839..b77a614 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; } /**
