diff --git a/extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/beanparam/BeanParamRecordDevModeTest.java b/extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/beanparam/BeanParamRecordDevModeTest.java new file mode 100644 index 0000000000000..88d5ce887ba93 --- /dev/null +++ b/extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/beanparam/BeanParamRecordDevModeTest.java @@ -0,0 +1,42 @@ +package io.quarkus.resteasy.reactive.server.test.beanparam; + +import static io.restassured.RestAssured.when; +import static org.hamcrest.CoreMatchers.is; + +import java.util.function.Supplier; + +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; + +public class BeanParamRecordDevModeTest { + + @RegisterExtension + static QuarkusDevModeTest TEST = new QuarkusDevModeTest() + .setArchiveProducer(new Supplier<>() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class).addClasses(FirstAndSecondResource.class, + FirstAndSecondResource.Param.class); + } + }); + + @Test + void test() { + when().get("fs/foo/bar") + .then() + .statusCode(200) + .body(is("foo-bar")); + + TEST.modifySourceFile(FirstAndSecondResource.class, (orig) -> orig.replace("-", "#")); + + when().get("fs/foo/bar") + .then() + .statusCode(200) + .body(is("foo#bar")); + } + +} diff --git a/extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/beanparam/FirstAndSecondResource.java b/extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/beanparam/FirstAndSecondResource.java new file mode 100644 index 0000000000000..27e3fa187def0 --- /dev/null +++ b/extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/beanparam/FirstAndSecondResource.java @@ -0,0 +1,20 @@ +package io.quarkus.resteasy.reactive.server.test.beanparam; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestPath; + +@Path("fs") +public class FirstAndSecondResource { + + @Path("{first}/{second}") + @GET + public String firstAndSecond(Param param) { + return param.first() + "-" + param.second(); + } + + public record Param(@RestPath String first, @RestPath String second) { + + } +} diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/RecordBeanParamExtractor.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/RecordBeanParamExtractor.java index 72a16cd0371a0..03e8f970ae9c0 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/RecordBeanParamExtractor.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/RecordBeanParamExtractor.java @@ -2,7 +2,6 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext; import org.jboss.resteasy.reactive.server.injection.ResteasyReactiveInjectionContext; @@ -13,8 +12,8 @@ public class RecordBeanParamExtractor implements ParameterExtractor { public RecordBeanParamExtractor(Class target) { try { - factoryMethod = MethodHandles.lookup().findStatic(target, "__quarkus_rest_inject", - MethodType.methodType(target, ResteasyReactiveInjectionContext.class)); + factoryMethod = MethodHandles.lookup() + .unreflect(target.getMethod("__quarkus_rest_inject", ResteasyReactiveInjectionContext.class)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException("Failed to find target generated factory method on record @BeanParam type", e); } @@ -27,7 +26,6 @@ public Object extractParameter(ResteasyReactiveRequestContext context) { } catch (RuntimeException e) { throw e; } catch (Throwable e) { - e.printStackTrace(); throw new RuntimeException("Failed to invoke generated factory method on record @BeanParam type", e); } }