Skip to content

Commit

Permalink
Merge pull request #26110 from geoand/#26088
Browse files Browse the repository at this point in the history
Ensure that @ServerResponseFilter honors @namebinding
  • Loading branch information
geoand authored Jun 14, 2022
2 parents bdf44dd + 6006ec9 commit d3a7fbe
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 d3a7fbe

Please sign in to comment.