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

Resteasy Reactive: Headers manipulated in ServerRequestFilter are not injected properly into rest method #19317

Closed
andreas-eberle opened this issue Aug 10, 2021 · 4 comments · Fixed by #19333
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@andreas-eberle
Copy link
Contributor

Describe the bug

When modifying or create a new header in a @ServerRequestFilter annotated method (with or without preMatching = true) does not have an effect on method paramteres injected with @RestHeader or @HeaderParam.

E.g. for a method like

@GET
	@Produces(MediaType.TEXT_PLAIN)
	public String hello(
			@RestHeader("new-header") String newHeader,
			@RestHeader(HttpHeaders.USER_AGENT) String userAgent,
			HttpHeaders httpHeaders
	) { ... }

you will get the original header for the user agent field, no matter what you set to the headers via ContainerRequestContext.getHeaders().putSingle() in the @ServerRequestFilter annotated method.

However, the modified headers are available in the HttpHeaders object you can inject into the method.

Expected behavior

The injected headers should reflect the modified values.

Actual behavior

The injected headers contain the original request headers instead of the modified ones, which are only available from the HttpHeaders object.

How to Reproduce?

Reproducer:
2021-08-10_resteasy-reactive-modify-headers.zip

  1. Download and unzip
  2. Start quarkus with ./gradlew quarkusDev
  3. Go to http://localhost:8080/hello
  4. You will get a response listing the injected header value as well as the value available from the HttpHeaders object. I'd expect them to be the same.
  5. Classes NewHeaderCreatingRequestFilter and UserAgentRequestFilter create a new header and modifiy the user agent header respectively.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.1

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@andreas-eberle andreas-eberle added the kind/bug Something isn't working label Aug 10, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 10, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Aug 10, 2021

I am on PTO (and I think the other folks mentioned by the bot are as well), so it might be a while before we take a look

@andreas-eberle
Copy link
Contributor Author

Thanks for the update. Have a good time!

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Aug 11, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Aug 11, 2021
@quarkus-bot quarkus-bot bot added this to the 2.2 - main milestone Aug 16, 2021
@andreas-eberle
Copy link
Contributor Author

Thanks @stuartwdouglas !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants