Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 7.4.5, 7.5.0
-
Fix Version/s: None
-
Component/s: Client
-
Labels:None
-
Environment:java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.9) (fedora-54.1.9.9.fc14-i386)
OpenJDK Server VM (build 19.0-b09, mixed mode)
-
Number of attachments :
Description
waitForDone() never returns if onException,onConnectionFailed when RedirectListener is running.
I noticed that my exchange wasn't getting called if the next request after a 301/302 redirect fails with onConnectionFailed() or onException(). Looks like RedirectListener disables deligating and then doesn't specifically re-enable it in these cases: HttpEventListenerWrapper ends up dropping the onException,onConnectionFailed() on the floor.
Here is an extract from a test case which can reproduce this:
bs.accept do |sock| sock.write "HTTP/1.1 302 Found\r\n" sock.write "Location: http://localhost:54929/no-exist\r\n" sock.write "Content-Type: text/plain\r\n" sock.write "Transfer-Encoding: chunked\r\n" sock.write "\r\n" sock.write "FF3DF\r\n" sock.write "An incomplete chunk" sock.write "An incomplete chunk" sock.write "An incomplete chunk" sock.close end
waitForDone() never returns in this case.
I was able to fix this by overriding RedirectListener with the following methods. Please let me know if you would like a patch on github or some other place for this:
/**
- Always delegate failed connection
*/
@Override
public void onConnectionFailed( Throwable ex ) { setDelegatingRequests( true ); setDelegatingResponses( true ); super.onConnectionFailed( ex ); }
/**
- Always delegate onException
*/
@Override
public void onException( Throwable ex ) { setDelegatingRequests( true ); setDelegatingResponses( true ); super.onException( ex ); }
Ooops, I can't edit above so here is better rendering of fix: