AsyncHttpClient / async-http-client

Asynchronous Http and WebSocket Client library for Java
Other
6.28k stars 1.59k forks source link

timeout.TimeoutTimerTask.appendRemoteAddress throws NPE #1403

Closed nrapesh closed 7 years ago

nrapesh commented 7 years ago

I use intellij and and I am facing an issue while running tests in PerRequestTimeoutTest . If I run all the tests in this file all of them pass but when I try to run an individual test it fails.

This is the scenarios - 1) Ran PerRequestTimeoutTest#testGlobalRequestTimeout I looked into logs and found this 2017-04-26 11:38:48,079 [pool-1-thread-1] WARN io.netty.util.HashedWheelTimer - An exception was thrown by TimerTask. java.lang.NullPointerException: null at org.asynchttpclient.netty.timeout.TimeoutTimerTask.appendRemoteAddress(TimeoutTimerTask.java:59) at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:48) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:661) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:736) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:464) at java.lang.Thread.run(Thread.java:745)

This implies TimeoutTimerTask ran before setResolvedRemoteAddress was called.

2 ) Ran all tests from PerRequestTimeoutTest - found this in logs for testGlobalRequestTimeout 2017-04-26 11:45:19,727 [pool-3-thread-1] DEBUG org.asynchttpclient.netty.timeout.TimeoutTimerTask - Request timeout to localhost/127.0.0.1:50766 after 100 ms for NettyResponseFuture{currentRetry=0, isDone=0, isCancelled=0, asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@5b61eb9d, nettyRequest=org.asynchttpclient.netty.request.NettyRequest@7d5e0e87, future=java.util.concurrent.CompletableFuture@238dde0b[Not completed, 1 dependents], uri=http://localhost:50766/foo/test, keepAlive=true, redirectCount=0, timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@2c779ae5, inAuth=0, statusReceived=0, touch=1493187319526} after 204 ms

This implies setResolvedRemoteAddress was called before TimeoutTimerTask ran.

I am unable to figure out why would this happen. Is there some caching going on from previous requests which would help in resolving remoteAddress thus making tests pass when all of them ran ?

Also due to this issue there is a possibility that it might block the calling thread forever in the scenario TimeoutTimerTask failed and no response was received from server

slandelle commented 7 years ago

Already fixed, duplicate of #1402