From 6006ec9eb9895209da9526e1b029e132908d7b04 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 14 Jun 2022 11:26:08 +0300 Subject: [PATCH] Ensure that @ServerResponseFilter honors @NameBinding Fixes: #26088 --- .../deployment/ResteasyReactiveScanningProcessor.java | 3 +++ .../server/test/customproviders/CustomFiltersTest.java | 9 +++++---- .../server/test/customproviders/MetalFilter.java | 10 +++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java index be895cd1977ea..93047b9d68ee7 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java @@ -336,6 +336,9 @@ public void handleCustomAnnotatedMethods( generated.getGeneratedClassName()) .setRegisterAsBean(false)// it has already been made a bean .setPriority(generated.getPriority()); + if (!generated.getNameBindingNames().isEmpty()) { + builder.setNameBindingNames(generated.getNameBindingNames()); + } additionalContainerResponseFilters.produce(builder.build()); } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/CustomFiltersTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/CustomFiltersTest.java index fa010c71be852..e92475042209a 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/CustomFiltersTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/CustomFiltersTest.java @@ -31,13 +31,14 @@ public JavaArchive get() { @Test public void testFilters() { - Headers headers = RestAssured.given().header("some-input", "bar").get("/custom/req") + Headers responseHeaders = RestAssured.given().header("some-input", "bar").get("/custom/req") .then().statusCode(200).body(Matchers.containsString("/custom/req-bar-null")).extract().headers(); - assertThat(headers.getValues("java-method")).containsOnly("filters"); + assertThat(responseHeaders.getValues("java-method")).containsOnly("filters"); Assertions.assertEquals(3, AssertContainerFilter.COUNT.get()); + assertThat(responseHeaders.getValues("very")).isEmpty(); - headers = RestAssured.given().header("some-input", "bar").get("/custom/metal") + responseHeaders = RestAssured.given().header("some-input", "bar").get("/custom/metal") .then().statusCode(200).body(Matchers.containsString("/custom/metal-bar-metal")).extract().headers(); - assertThat(headers.getValues("java-method")).containsOnly("metal"); + assertThat(responseHeaders.getValues("very")).containsOnly("heavy"); } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/MetalFilter.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/MetalFilter.java index f23d62aa2dfef..62335776d3343 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/MetalFilter.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customproviders/MetalFilter.java @@ -1,14 +1,22 @@ package io.quarkus.resteasy.reactive.server.test.customproviders; import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; import org.jboss.resteasy.reactive.server.ServerRequestFilter; +import org.jboss.resteasy.reactive.server.ServerResponseFilter; public class MetalFilter { @Metal @ServerRequestFilter - public void headBang(ContainerRequestContext requestContext) { + public void headBangIn(ContainerRequestContext requestContext) { requestContext.getHeaders().putSingle("heavy", "metal"); } + + @Metal + @ServerResponseFilter + public void headBangOut(ContainerResponseContext responseContext) { + responseContext.getHeaders().putSingle("very", "heavy"); + } }