Restlet 2.1.0 hangs #675

Closed
devmao opened this Issue Oct 17, 2012 · 7 comments

4 participants

@devmao

This simple code hanged restlet after few loops!

The 2.1-RC6 it's also affected but not the 2.1-RC5.

The server:

public class RestletTestServer extends ServerResource {

    public static void main(String[] args) throws Exception {
        new Server(Protocol.HTTP, 8182, RestletTestServer.class).start();
    }

    @Get
    public String toString() {
        return "Ciao Hola Bonjour Hello Ahoj";
    }
}

The client:

public class RestletTestSimpleClient {

    static final String URL = "http://localhost:8182/";
    static final long DELAY = 2 * 60 * 1000;

    public static void main(String[] args) throws Exception {

        while (true) {

            System.out.println(new Date() + ": Sending the first call...");
            new ClientResource(URL).get().write(System.out);
            System.out.println("");

            System.out.println(new Date() + ": Sleeping " + DELAY);
            Thread.sleep(DELAY);

            System.out.println(new Date() + ": Sending the second call...");
            new ClientResource(URL).get().write(System.out);
            System.out.println("");
        }
    }
}

My system:

$ uname -a
Linux mao-linux 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

$ java -version
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)
@alepac

I'm also able to replicate the issue on Windows.

Here is the ouput of the simple client:

C:\Documents and Settings\alepac\Desktop\test>java -jar client.jar
Fri Oct 19 16:36:27 CEST 2012: Sending the first call...
Starting the internal [HTTP/1.1] client
Ciao Hola Bonjour Hello Ahoj
Fri Oct 19 16:36:28 CEST 2012: Sleeping 120000
Fri Oct 19 16:38:28 CEST 2012: Sending the second call...
Starting the internal [HTTP/1.1] client
Ciao Hola Bonjour Hello Ahoj
Fri Oct 19 16:38:28 CEST 2012: Sending the first call...
Starting the internal [HTTP/1.1] client
Stopping the internal [HTTP/1.1] client
Stopping the internal [HTTP/1.1] client
Ciao Hola Bonjour Hello Ahoj
Fri Oct 19 16:38:29 CEST 2012: Sleeping 120000
Fri Oct 19 16:40:28 CEST 2012: Sending the second call...
Starting the internal [HTTP/1.1] client

My system:

C:\Documents and Settings\alepac\Desktop\test>java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Client VM (build 23.3-b01, mixed mode, sharing)
@jlouvel
Restlet member

Could you try again with version 2.1.1? A related fix was made.

@avandecreme

I just tested and the above problem is fixed.
However the one I posted on stackoverflow is still here, apparently it was not the same bug but with the same workaround.

For the bug in stackoverflow, I actually can only reproduce it with Jetty (I tried the Internal connector, the Simple connector and Tomcat).
Looking into the code, I am not sure wether it is a bug with Jetty or a misuse of Jetty by restlet.
Jetty is closing the outputstream on the idle timeout and nothing reopen it when the server send a response to the client.

@jlouvel
Restlet member

Thanks for the follow up.

Could you open a new issue related to the Jetty issue in GitHub with a pointer to the SoF question?

@avandecreme

Here it is: #705

@jlouvel
Restlet member

Thanks, let's close this issue then.

@jlouvel jlouvel closed this Jan 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment