Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that @ServerResponseFilter honors @NameBinding #26110

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}