Skip to content

Commit

Permalink
Merge pull request #23745 from geoand/#23732
Browse files Browse the repository at this point in the history
Prevent SubResources from causing a NPE
  • Loading branch information
geoand authored Feb 16, 2022
2 parents 2e7e5c9 + ffa15de commit 29b5a8d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ ConsoleCommandBuildItem openCommand(HttpRootPathBuildItem rp, NonApplicationRoot
cp = "/" + cp;
}
for (ResourceMethod method : clazz.getMethods()) {
if (method.getHttpMethod() == null) {
continue;
}
if (!method.getHttpMethod().equals("GET")) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package io.quarkus.resteasy.reactive.server.test.devmode;

import static org.hamcrest.CoreMatchers.equalTo;

import java.util.function.Supplier;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusDevModeTest;
import io.restassured.RestAssured;

public class SubResourceDevModeTest {

@RegisterExtension
static QuarkusDevModeTest TEST = new QuarkusDevModeTest()
.setArchiveProducer(new Supplier<JavaArchive>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(Resource.class, SubResource.class);
}

});

@Test
public void test() {
RestAssured.get("/test/sub")
.then()
.statusCode(200)
.body(equalTo("hello"));
}

@Path("test")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.TEXT_PLAIN)
public static class Resource {
@Context
ResourceContext resourceContext;

@Path("sub")
public SubResource subresource() {
return new SubResource();
}
}

public static class SubResource {

@GET
public String hello() {
return "hello";
}
}
}

0 comments on commit 29b5a8d

Please sign in to comment.