Repository: cxf Updated Branches: refs/heads/3.0.x-fixes c9b4c04b2 -> 7557d5fcf
[CXF-6655] Do not early fail when the HTTPConduit is initialized before a target address is set in the client (and there's no reference to a wsdl contract), perhaps because the user is setting up a proxy in the conduit; try using the endpoint address set in the request context just before performing the invocation (and fail if that's not available either). Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3ed84963 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3ed84963 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3ed84963 Branch: refs/heads/3.0.x-fixes Commit: 3ed849631e4f817d5d988e4d642575c9dd5b7b16 Parents: 6dd411a Author: Alessio Soldano <asold...@redhat.com> Authored: Fri Oct 30 14:09:32 2015 +0100 Committer: Alessio Soldano <asold...@redhat.com> Committed: Fri Oct 30 15:27:47 2015 +0100 ---------------------------------------------------------------------- .../apache/cxf/transport/http/HTTPConduit.java | 38 ++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/3ed84963/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 83e5960..7f9b6fd 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 @@ -676,10 +676,14 @@ public abstract class HTTPConduit setAndGetDefaultAddress(); if (result == null) { if (pathInfo == null && queryString == null) { - message.put(Message.ENDPOINT_ADDRESS, defaultAddress.getString()); + if (defaultAddress != null) { + message.put(Message.ENDPOINT_ADDRESS, defaultAddress.getString()); + } return defaultAddress; } - message.put(Message.ENDPOINT_ADDRESS, defaultAddress.getString()); + if (defaultAddress != null) { + message.put(Message.ENDPOINT_ADDRESS, defaultAddress.getString()); + } } // REVISIT: is this really correct? @@ -688,8 +692,12 @@ public abstract class HTTPConduit } if (queryString != null) { result = result + "?" + queryString; - } - return result.equals(defaultAddress.getString()) ? defaultAddress : new Address(result); + } + if (defaultAddress == null) { + return setAndGetDefaultAddress(result); + } else { + return result.equals(defaultAddress.getString()) ? defaultAddress : new Address(result); + } } /** @@ -726,12 +734,7 @@ public abstract class HTTPConduit if (defaultAddress == null) { if (fromEndpointReferenceType && getTarget().getAddress().getValue() != null) { defaultAddress = new Address(this.getTarget().getAddress().getValue()); - } else { - if (endpointInfo.getAddress() == null) { - throw new URISyntaxException("<null>", - "Invalid address. Endpoint address cannot be null.", - 0); - } + } else if (endpointInfo.getAddress() != null) { defaultAddress = new Address(endpointInfo.getAddress()); } } @@ -740,6 +743,21 @@ public abstract class HTTPConduit return defaultAddress; } + private Address setAndGetDefaultAddress(String curAddr) throws URISyntaxException { + if (defaultAddress == null) { + synchronized (this) { + if (defaultAddress == null) { + if (curAddr != null) { + defaultAddress = new Address(curAddr); + } else { + throw new URISyntaxException("<null>", + "Invalid address. Endpoint address cannot be null.", 0); + } + } + } + } + return defaultAddress; + } /** * This call places HTTP Header strings into the headers that are relevant * to the Authorization policies that are set on this conduit by