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

Create a new Resteasy Context Map #13335

Merged
merged 1 commit into from Nov 18, 2020
Merged

Conversation

stuartwdouglas
Copy link
Member

This provides a slight performance advantage,
but most importantly will prevent an existing
client context from interfering with the server one.

This can happen if the authentication layer is using
the REST client to access external services.

Fixes #13317

@ghost ghost added the area/resteasy label Nov 17, 2020
Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer to use the other addCloseableContextDataLevel because it also removes the context data map. If you don't you're fucking up any pending client context.

Map<Class<?>, Object> map = new HashMap<>();
map.put(SecurityContext.class, new QuarkusResteasySecurityContext(request, routingContext));
map.put(RoutingContext.class, routingContext);
ResteasyContext.pushContextDataMap(map);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be using the variant that creates a new Closeable context : addCloseableContextDataLevel that you can use in a try-with-resource.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about async requests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async requests need to capture this context anyway, since we've no idea what thread they'll be in when they get executed. This doesn't destroy anything, BTW. It just pops it from the current context stack and restore the previous context map.

This provides a slight performance advantage,
but most importantly will prevent an existing
client context from interfering with the server one.

This can happen if the authentication layer is using
the REST client to access external services.

Fixes quarkusio#13317
@gsmet gsmet merged commit acdd04d into quarkusio:master Nov 18, 2020
@ghost ghost added this to the 1.11 - master milestone Nov 18, 2020
@gsmet gsmet modified the milestones: 1.11 - master, 1.10.0.Final Nov 18, 2020
@gsmet gsmet modified the milestones: 1.10.0.Final, 1.7.6.Final Dec 11, 2020
@paulrobinson paulrobinson added the kind/enhancement New feature or request label Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quarkus HTTP response gets messed up under load
6 participants