Author: dkulp
Date: Thu Feb 26 16:07:04 2009
New Revision: 748192
URL: http://svn.apache.org/viewvc?rev=748192&view=rev
Log:
Another thread safety fix to try and get the JAXWS test that randomly fails on
Hudson to pass. (couldn't get it to fail on either of my boxes)
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=748192&r1=748191&r2=748192&view=diff
==============================================================================
---
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Thu Feb 26 16:07:04 2009
@@ -442,13 +442,22 @@
* UnitTest that will of course break, should the calls to the URL
Connection
* Factory get altered.
*/
- protected void retrieveConnectionFactory() {
+ protected synchronized void retrieveConnectionFactory() {
connectionFactory =
AbstractHTTPTransportFactory.getConnectionFactory(this);
}
- protected void retrieveConnectionFactory(String url) {
+ protected synchronized void retrieveConnectionFactory(String url) {
connectionFactory =
AbstractHTTPTransportFactory.getConnectionFactory(this, url);
}
+
+ protected synchronized HttpURLConnectionFactory getConnectionFactory(URL
url) {
+ if (connectionFactory == null
+ || !url.getProtocol().equals(connectionFactory.getProtocol())) {
+ retrieveConnectionFactory(url.toString());
+ }
+
+ return connectionFactory;
+ }
/**
* Prepare to send an outbound HTTP message over this http conduit to a
* particular endpoint.
@@ -481,9 +490,8 @@
// The need to cache the request is off by default
boolean needToCacheRequest = false;
- HttpURLConnection connection =
- connectionFactory.createConnection(
- getProxy(clientSidePolicy), currentURL);
+ HttpURLConnection connection = getConnectionFactory(currentURL)
+ .createConnection(getProxy(clientSidePolicy), currentURL);
connection.setDoOutput(true);
//TODO using Message context to decided HTTP send properties
@@ -632,7 +640,7 @@
connection.connect();
trustDecider.establishTrust(
getConduitName(),
- connectionFactory.getConnectionInfo(connection),
+
getConnectionFactory(connection.getURL()).getConnectionInfo(connection),
message);
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Trust Decider "
@@ -692,13 +700,6 @@
}
result = getURL().toString();
message.put(Message.ENDPOINT_ADDRESS, result);
- } else {
- if (connectionFactory == null
- || !result.startsWith(connectionFactory.getProtocol() + ":/"))
{
-
- connectionFactory = null;
- retrieveConnectionFactory(result);
- }
}
// REVISIT: is this really correct?
@@ -1612,15 +1613,7 @@
// Disconnect the old, and in with the new.
connection.disconnect();
- if (connectionFactory.getProtocol().equals(newURL.getProtocol())) {
- connection =
- connectionFactory.createConnection(
- getProxy(clientSidePolicy), newURL);
- } else {
- connection =
AbstractHTTPTransportFactory.getConnectionFactory(this, newURL.toString())
- .createConnection(getProxy(clientSidePolicy), newURL);
- }
-
+ connection =
getConnectionFactory(newURL).createConnection(getProxy(clientSidePolicy),
newURL);
connection.setDoOutput(true);
// TODO: using Message context to deceided HTTP send properties
connection.setConnectTimeout((int)getClient().getConnectionTimeout());
Modified:
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java?rev=748192&r1=748191&r2=748192&view=diff
==============================================================================
---
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
(original)
+++
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java
Thu Feb 26 16:07:04 2009
@@ -93,6 +93,10 @@
protected void retrieveConnectionFactory() {
// do nothing. i.e do not change the connectionFactory field.
}
+ protected void retrieveConnectionFactory(String s) {
+ // do nothing. i.e do not change the connectionFactory field.
+ }
+
}
/**
* @throws java.lang.Exception