Skip to content

Instantly share code, notes, and snippets.

@tbroyer
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbroyer/789307a92c77ffff73d5 to your computer and use it in GitHub Desktop.
Save tbroyer/789307a92c77ffff73d5 to your computer and use it in GitHub Desktop.
RESTEASY-1077: Regression in Resteasy 3.0.8.Final (vs. 3.0.6.Final)
import static org.junit.Assert.assertEquals;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer;
import org.jboss.resteasy.test.TestPortProvider;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Copy this class in a project using resteasy-netty or resteasy-netty4 and run the test.
* The test will fail with Resteasy 3.0.8.Final, but pass with 3.0.6.Final.
* It'll also pass if you remove the trailing slash in {@code generateURL("/test/")}.
*/
public class ResteasyTrailingSlashTest {
private static NettyJaxrsServer server;
@Path("/")
public static class Resource {
@GET
@Path("/test/")
@Produces(MediaType.TEXT_PLAIN)
public String get() {
return "hello world";
}
}
@BeforeClass
public static void init() throws Exception {
server = new NettyJaxrsServer();
server.setPort(TestPortProvider.getPort());
server.setRootResourcePath("");
server.setSecurityDomain(null);
server.start();
server.getDeployment().getRegistry().addPerRequestResource(Resource.class);
}
@AfterClass
public static void stop() throws Exception {
server.stop();
}
@Test
public void testTrailingSlash() throws Exception {
Client client = ClientBuilder.newClient();
String val = client.target(TestPortProvider.generateURL("/test/"))
// String val = client.target(TestPortProvider.generateURL("/test"))
.request().get(String.class);
assertEquals("hello world", val);
}
}
@tbroyer
Copy link
Author

tbroyer commented Jun 17, 2014

Error log:

javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8081/test/
    at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:112) ~[resteasy-jaxrs-3.0.8.Final.jar:?]
    at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43) ~[resteasy-jaxrs-3.0.8.Final.jar:?]
    at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48) ~[resteasy-jaxrs-3.0.8.Final.jar:?]
    at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444) ~[resteasy-jaxrs-3.0.8.Final.jar:?]
    at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234) [resteasy-jaxrs-3.0.8.Final.jar:?]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171) [resteasy-jaxrs-3.0.8.Final.jar:?]
    at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83) [resteasy-netty-3.0.8.Final.jar:?]
    at org.jboss.resteasy.plugins.server.netty.RequestHandler.messageReceived(RequestHandler.java:56) [resteasy-netty-3.0.8.Final.jar:?]
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) [netty-3.9.2.Final.jar:?]
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.9.2.Final.jar:?]
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) [netty-3.9.2.Final.jar:?]
    at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43) [netty-3.9.2.Final.jar:?]
    at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67) [netty-3.9.2.Final.jar:?]
    at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314) [netty-3.9.2.Final.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_55]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_55]
    at java.lang.Thread.run(Thread.java:744) [?:1.7.0_55]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment