Skip to content

Commit

Permalink
RR: Fix abort chain order for quarkusio#22408
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Jan 19, 2022
1 parent abfa9c8 commit 8960603
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.quarkus.resteasy.reactive.server.test.simple;

import java.util.function.Supplier;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.jboss.resteasy.reactive.server.ServerResponseFilter;
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.QuarkusUnitTest;
import io.restassured.RestAssured;

public class Issue22408TestCase {

@RegisterExtension
static QuarkusUnitTest test = new QuarkusUnitTest()
.setArchiveProducer(new Supplier<JavaArchive>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(MyFilters.class, MyResource.class);
}
});

@Test
public void simpleTest() {
RestAssured.get("/")
.then().statusCode(204);
}

public static class MyFilters {

@ServerExceptionMapper
public Response mapException(RuntimeException x) {
// this should get us a 204 which masks the original 405
return null;
}

@ServerResponseFilter
public void responseFilter(ContainerResponseContext ctx) {
// NPE because the response was not set yet
ctx.getEntity();
}
}

@Path("/")
public static class MyResource {
// by calling a GET here we generate a 405
@POST
public String get() {
return "Hello";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public BeanFactory.BeanInstance<?> apply(Class<?> aClass) {
abortHandlingChain.add(interceptorDeployment.getGlobalInterceptorHandler());
}
abortHandlingChain.add(new ExceptionHandler());
abortHandlingChain.add(ResponseHandler.NO_CUSTOMIZER_INSTANCE);
if (!interceptors.getContainerResponseFilters().getGlobalResourceInterceptors().isEmpty()) {
abortHandlingChain.addAll(interceptorDeployment.getGlobalResponseInterceptorHandlers());
}
abortHandlingChain.add(ResponseHandler.NO_CUSTOMIZER_INSTANCE);
abortHandlingChain.add(new ResponseWriterHandler(dynamicEntityWriter));
// sanitise the prefix for our usage to make it either an empty string, or something which starts with a / and does not
// end with one
Expand Down

0 comments on commit 8960603

Please sign in to comment.