Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316119 - MaxIdleTime has no effect on bio SocketConnector
Summary: MaxIdleTime has no effect on bio SocketConnector
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 7.0.2.RC0   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-08 08:31 EDT by Kiyoshi Kamishima CLA
Modified: 2010-06-08 23:26 EDT (History)
1 user (show)

See Also:


Attachments
A little program to reproduce the issue. (2.45 KB, application/octet-stream)
2010-06-08 08:33 EDT, Kiyoshi Kamishima CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kiyoshi Kamishima CLA 2010-06-08 08:31:39 EDT
Build Identifier: 7.1.1.v20100517

Starting from Jetty 7.1.1, setting MaxIdleTime on a SocketConnector seems to have no effect. It is apparently a side-effect of the fix for Bug 312243.
The MaxIdleTime value is specified as an argument for a constructor for SocketEndPoint class. However, SoTimeout property is not set during the call to the constructor.
Later, SocketConnector#customize() tries to set MaxIdleTime on the connection again though a call to SocketEndPoint#setMaxIdleTime(), but it erroneously considers the socket being already configured during the constructor.

I thinks the call to super.setMaxIdleTime() must be replaced with the call to (this.)setMaxIdleTime(), so that SoTimeout property is set correctly during the construction.
Note that a call to super.setMaxIdleTime() in another overloaded constructor (with only one parameter) should be left as it is, because it is no use to set SoTimeout property to its own SoTimeout value.

public class SocketEndPoint extends StreamEndPoint
{
    public SocketEndPoint(Socket socket)
    	throws IOException	
    {
        super(socket.getInputStream(),socket.getOutputStream());
        _socket=socket;
        super.setMaxIdleTime(_socket.getSoTimeout()); // This should be left intact.
    }

    protected SocketEndPoint(Socket socket, int maxIdleTime)
        throws IOException      
    {
        super(socket.getInputStream(),socket.getOutputStream());
        _socket=socket;
        super.setMaxIdleTime(maxIdleTime); // It does NOTHING on _socket!!
    }

    @Override
    public void setMaxIdleTime(int timeMs) throws IOException
    {
        if (timeMs!=getMaxIdleTime())
            _socket.setSoTimeout(timeMs>0?timeMs:0);
        super.setMaxIdleTime(timeMs);
    }
}


Reproducible: Always

Steps to Reproduce:
1. Compile and run the attached program with Jetty >= 7.1.1.
javac -cp jetty-servlet-7.1.1.v20100517.jar;servlet-api-2.5.jar;. Prog.java
java -cp jetty-servlet-7.1.1.v20100517.jar;servlet-api-2.5.jar;. Prog
2. You see a sad face.
2010-06-08 20:47:47.316:INFO::jetty-7.1.1.v20100517
2010-06-08 20:47:47.343:INFO::Started SocketConnector@0.0.0.0:9999
OOPS :-<

If you run it with Jetty <= 7.1.0, you make it happy.
2010-06-08 20:47:56.365:INFO::jetty-7.1.0.v20100505
2010-06-08 20:47:56.392:INFO::Started SocketConnector@0.0.0.0:9999
GOOD :-)
Comment 1 Kiyoshi Kamishima CLA 2010-06-08 08:33:18 EDT
Created attachment 171392 [details]
A little program to reproduce the issue.
Comment 2 Greg Wilkins CLA 2010-06-08 23:26:39 EDT
thanks for the excellent bug report and diagnosis.
Committed in r1947 and will be released in 7.1.4 later this week.