On 30/06/2010 17:55, Daniel Kulp wrote:
On Wednesday 30 June 2010 1:59:27 am Jim Talbut wrote:
The problem is that the timeout in the test is too low, so this fixes it:
Index:
src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
===================================================================
---
src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
(revision 959071)
+++
src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
(working copy)
@@ -149,7 +149,7 @@

           DispatchImpl dispImpl = (DispatchImpl)disp;
           HTTPConduit cond =
(HTTPConduit)dispImpl.getClient().getConduit(); -
cond.getClient().setConnectionTimeout(500);
+        cond.getClient().setConnectionTimeout(5000);

           InputStream is =
getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
           SOAPMessage soapReqMsg =
MessageFactory.newInstance().createMessage(null, is);

/Now/ the question is why does it take more than 0.5s to fail to connect
to a local endpoint
(http://localhost:4986/SOAPDispatchService/SoapDispatchPort) on my PC?
I'm still looking into that.

Well, no.   The test ISN'T supposed to connect to the endpoint.   It's
supposed to test the failure condition where there isn't anything running on
that port.    That's why the timeout is so low as it's SUPPOSED to timeout.
I can tell that :)
Thus, if the test is failing, it's either successfully connecting to something
or the thrown fault is wrong.
In which case it would appear that the thrown fault is wrong, but why not on your hudson builds?

Can you try keeping it at 500, but then put a System.gc() and/or a
Thread.yield() or something before it to see if it just needs a little extra
time.
I went for:
        System.gc();
        Thread.sleep(1000);
        System.gc();
I also tried changing the port to one that I simply know isn't in use, in each the result is the same:
java.lang.AssertionError: java.net.SocketTimeoutException


The TestUtil.getPortNumber("fake-port") gets a "unique" port number by
allocating a server socket, getting the port number, then immediately closing
it.   Maybe it's taking a little extra time to close that port.    Also, try
doing a printStackTrace on the caught exception prior to the assert.   I'd
like to know the trace where the SocketTimeoutException is coming from.
According to javadocs, we SHOULD be getting the ConnectException, not the
SocketTimeoutException.
Not sure I concur with your interpretation of the javadoc, both http://java.sun.com/javase/6/docs/api/java/net/Socket.html#connect%28java.net.SocketAddress%29 and http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#connect%28%29 say that a SocketTimeoutException is returned if the timeout expires whilst connecting.

The stack trace is:
Running org.apache.cxf.systest.dispatch.DispatchClientServerTest
javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.DispatchImpl.mapException(DispatchImpl.java:243)
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:335)
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:217)
at org.apache.cxf.systest.dispatch.DispatchClientServerTest.testTimeout(DispatchClientServerTest.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:109)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1017) Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking http://localhost:1534/SOAPDispatchService/SoapDispatchPort: connect timed out at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1973) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1958) at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47) at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:188) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:244)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:487)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:300)
        at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:328)
        ... 32 more
Caused by: java.net.SocketTimeoutException: connect timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:904) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1869) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1821) at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1889)
        ... 43 more

The interesting thing, found after a bit of experimentation at work today, is that trying to connect to a nonexistant localhost port on a Windows box takes ~1s to fail, but on either Linux or MacOS it fails immediately. So on Linux and MacOS you get a ConnectException because it has failed to connect, but on Windows it times out instead.

Jim

Reply via email to