Created
January 4, 2013 08:50
-
-
Save anonymous/4450991 to your computer and use it in GitHub Desktop.
ClosedChannelException when using netty and resteasy with concurrent requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is the testcase | |
class RestNodeStarterTest { | |
ResteasyDeployment deployment; | |
SomeApi someApi; | |
NettyJaxrsServer server; | |
@Before | |
public void setUp() { | |
someApi = new SomeApi(); | |
deployment = new ResteasyDeployment(); | |
deployment.setResources(Arrays.asList(someApi)); | |
server = new NettyJaxrsServer(); | |
server.setDeployment(deployment); | |
int port = 3000; | |
server.setPort(port); | |
server.start(); | |
} | |
@Test | |
//dummy test to make the server stand still | |
public void testBasicFlow() throws Exception { | |
//when i execute the request with curl it seems fine | |
//curl --include http://127.0.0.1:3000/api/1234 | |
Thread.sleep(100000) | |
//but when i use ab tool for more requests, i get the java.nio.channels.ClosedChannelException | |
//ab -n 100 -c 1 http://127.0.0.1:3000/api/1234 | |
} | |
@After | |
public void tearDown() { | |
server.stop() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is the rest resource | |
@Path("/") | |
public class SomeApi { | |
@GET | |
@Path("api/{someValue}") | |
public Response getSomeStuff(@PathParam("someValue") String someValue) { | |
return Response.status(200).entity("Parameter is: " + someValue).build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment