Skip to content

Commit

Permalink
Ensure that @ServerResponseFilter honors @namebinding
Browse files Browse the repository at this point in the history
Fixes: quarkusio#26088
(cherry picked from commit 6006ec9)
  • Loading branch information
geoand authored and gsmet committed Jun 15, 2022
1 parent 8c509ae commit f9dc29e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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");
}
}

0 comments on commit f9dc29e

Please sign in to comment.