You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/09/14 19:25:08 UTC
svn commit: r997002 - in /cxf/branches/2.2.x-fixes: ./
api/src/main/java/org/apache/cxf/endpoint/
rt/transports/http/src/main/java/org/apache/cxf/transport/http/
systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/
Author: dkulp
Date: Tue Sep 14 17:25:08 2010
New Revision: 997002
URL: http://svn.apache.org/viewvc?rev=997002&view=rev
Log:
Merged revisions 996809 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r996809 | ema | 2010-09-14 05:55:34 -0400 (Tue, 14 Sep 2010) | 1 line
[CXF-2991]:Configure the http client connection and receive timeout via BindingProvider.getRequestContext
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Client.java
cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties
cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Client.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Client.java?rev=997002&r1=997001&r2=997002&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Client.java (original)
+++ cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Client.java Tue Sep 14 17:25:08 2010
@@ -34,6 +34,8 @@ public interface Client extends Intercep
String REQUEST_CONTEXT = "RequestContext";
String RESPONSE_CONTEXT = "ResponseContext";
String KEEP_CONDUIT_ALIVE = "KeepConduitAlive";
+ String CONNECTION_TIMEOUT = "javax.xml.ws.client.connectionTimeout";
+ String RECEIVE_TIMEOUT = "javax.xml.ws.client.receiveTimeout";
/**
* Invokes an operation synchronously
Modified: cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=997002&r1=997001&r2=997002&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Tue Sep 14 17:25:08 2010
@@ -54,6 +54,7 @@ import org.apache.cxf.configuration.jsse
import org.apache.cxf.configuration.security.AuthorizationPolicy;
import org.apache.cxf.configuration.security.CertificateConstraintsType;
import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
+import org.apache.cxf.endpoint.Client;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.HttpHeaderHelper;
import org.apache.cxf.helpers.IOUtils;
@@ -502,8 +503,34 @@ public class HTTPConduit
HttpURLConnectionFactory f = getConnectionFactory(currentURL);
HttpURLConnection connection = f.createConnection(getProxy(csPolicy), currentURL);
- connection.setDoOutput(true);
-
+ connection.setDoOutput(true);
+ Map<String, Object> ctx = CastUtils.cast((Map<?, ?>)message.get(Message.INVOCATION_CONTEXT));
+ if (ctx != null) {
+ Map<String, Object> reqCtx = CastUtils.cast((Map<?, ?>)ctx.get(Client.REQUEST_CONTEXT));
+ if (reqCtx != null && reqCtx.get(Client.RECEIVE_TIMEOUT) != null) {
+ Object obj = reqCtx.get(Client.RECEIVE_TIMEOUT);
+ try {
+ csPolicy.setReceiveTimeout(Long.parseLong(obj.toString()));
+ } catch (NumberFormatException e) {
+ LOG.log(Level.WARNING, "INVALID_TIMEOUT_FORMAT", new Object[] {
+ Client.RECEIVE_TIMEOUT, obj.toString()
+ });
+ }
+
+ }
+ if (reqCtx != null && reqCtx.get(Client.CONNECTION_TIMEOUT) != null) {
+ Object obj = reqCtx.get(Client.CONNECTION_TIMEOUT);
+ try {
+ csPolicy.setReceiveTimeout(Long.parseLong(obj.toString()));
+ } catch (NumberFormatException e) {
+ LOG.log(Level.WARNING, "INVALID_TIMEOUT_FORMAT", new Object[] {
+ Client.CONNECTION_TIMEOUT, obj.toString()
+ });
+ }
+
+ }
+ }
+
long timeout = csPolicy.getConnectionTimeout();
if (timeout > Integer.MAX_VALUE) {
timeout = Integer.MAX_VALUE;
Modified: cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties?rev=997002&r1=997001&r2=997002&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties (original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties Tue Sep 14 17:25:08 2010
@@ -24,3 +24,4 @@ NULL_RESPONSE_MSG = Response object is n
DECOUPLED_RESPONSE_FAILED_MSG = Decouple response failed
MISSING_PATH_INFO = PATH_INFO not present in message context, multiplex id is unavailable. Ensure the portName passed to getCurrentEndpointReferenceId is correct if the service has multiple ports
INVALID_ENCODING_MSG = Invalid character set {0} in request.
+INVALID_TIMEOUT_FORMAT = Invalid name/value pair {0}={1} set in RequestConext
Modified: cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?rev=997002&r1=997001&r2=997002&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java Tue Sep 14 17:25:08 2010
@@ -170,6 +170,28 @@ public class ClientServerTest extends Ab
}
@Test
+ public void testTimeoutConfigutation() throws Exception {
+
+ SOAPService service = new SOAPService();
+ assertNotNull(service);
+
+ Greeter greeter = service.getPort(portName, Greeter.class);
+ updateAddressPort(greeter, PORT);
+ ((javax.xml.ws.BindingProvider)greeter).getRequestContext().put("javax.xml.ws.client.receiveTimeout",
+ "1");
+ try {
+ greeter.greetMe("test");
+ // remove fail() check to let this test pass in the powerful machine
+ } catch (Throwable ex) {
+ Object cause = null;
+ if (ex.getCause() != null) {
+ cause = ex.getCause();
+ }
+ assertTrue("Timeout cause is expected", cause instanceof java.net.SocketTimeoutException);
+ }
+ }
+
+ @Test
public void testNillable() throws Exception {
SOAPService service = new SOAPService();
assertNotNull(service);