Bug 55180 - connectionTimeout="-1" causes timeout can't be negative
connectionTimeout="-1" causes timeout can't be negative
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Connectors
7.0.30
PC All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-07-02 00:01 UTC by Roger Wang
Modified: 2013-07-03 04:09 UTC (History)
0 users



Attachments
fix (749 bytes, patch)
2013-07-02 02:16 UTC, Nick Bunn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Wang 2013-07-02 00:01:40 UTC
I configured server.xml like this:
connectionTimeout="-1" disableUploadTimeout="false" connectionUploadTimeout="200"
(maybe it is stupid to configure like this,if connectionTimeout=-1,can i make disableUploadTimeout=false?).
It will cause :

java.lang.IllegalArgumentException: timeout can't be negative
	at sun.nio.ch.SocketAdaptor.setSoTimeout(SocketAdaptor.java:361)
	at org.apache.coyote.http11.Http11NioProcessor.setSocketTimeout(Http11NioProcessor.java:251)
......
because of :
      if (!disableUploadTimeout) {
//endpoint.getSoTimeout()=-1.
           setSocketTimeout(endpoint.getSoTimeout());
       }

~~~~~~~~~~~~~~~~~~~~~~~~~
another thing:
if i configure connectionTimeout="0". 
in NioBlockingSelector.read(ByteBuffer buf, NioChannel socket, long readTimeout),readTimeout = 0, in case socket.read(buf) == 0, it make timeout=true.
if (readTimeout >= 0 && (keycount == 0))
    timedout = (System.currentTimeMillis() - time) >= readTimeout;
then throw the SocketTimeoutException().

thank you.
Comment 1 Nick Bunn 2013-07-02 02:16:35 UTC
Created attachment 30519 [details]
fix

Attached the patch to fix the first issue. 

Might need to discuss why it was chose to make -1 the infiniti timeout. When in the socket class 0 is infiniti. I'm sure there is good reason. Just a thought.
Comment 2 Violeta Georgieva 2013-07-02 07:39:48 UTC
Hi,

Thanks for the report and the patch. It was applied to trunk and 7.0.x and will be included in 7.0.42 onwards.


For the second problem you are facing Bug 55160. Instead of connectionUploadTimeout, connectionTimeout was set as readTimeout.

Regards
Violeta
Comment 3 Roger Wang 2013-07-03 00:23:54 UTC
excuse me, I think the second problem is different from the bug 55160.
because when connectionTimeout="0" disableUploadTimeout="true".
it will always throw socketTimeoutException if read ==0 (socket.read(buf)).
Thank you very much for your fixing.
Comment 4 Violeta Georgieva 2013-07-03 04:09:21 UTC
(In reply to Roger Wang from comment #3)
> excuse me, I think the second problem is different from the bug 55160.
> because when connectionTimeout="0" disableUploadTimeout="true".
> it will always throw socketTimeoutException if read ==0 (socket.read(buf)).
> Thank you very much for your fixing.

Please open a new bug for this particular problem.

Thanks
Violeta