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

Fix NPE in ClientResponseFilterRestHandler #45203

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

rober710
Copy link
Contributor

This is a fix similar to #41749
However, this one happens when there's a timeout during the processing. The stacktrace of the error is included below.

I have a reproducer for this issue: https://github.com/rober710/resteasy-reactive-reproducer2

Details:
        Error id ba11afe4-322d-4de6-b9ae-beb3410473de-1, jakarta.ws.rs.ProcessingException: java.lang.NullPointerException: Cannot invoke "org.jboss.resteasy.reactive.client.impl.ClientRequestContextImpl.getRestClientRequestContext()" because "requestContext" is null
Stack:
        jakarta.ws.rs.ProcessingException: java.lang.NullPointerException: Cannot invoke "org.jboss.resteasy.reactive.client.impl.ClientRequestContextImpl.getRestClientRequestContext()" because "requestContext" is null
        at org.jboss.resteasy.reactive.client.handlers.ClientResponseFilterRestHandler.handle(ClientResponseFilterRestHandler.java:25)
        at org.jboss.resteasy.reactive.client.handlers.ClientResponseFilterRestHandler.handle(ClientResponseFilterRestHandler.java:10)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.invokeHandler(AbstractResteasyReactiveContext.java:231)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext$1.lambda$execute$0(RestClientRequestContext.java:324)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:270)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:252)
        at io.vertx.core.impl.ContextInternal.lambda$runOnContext$0(ContextInternal.java:50)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.NullPointerException: Cannot invoke "org.jboss.resteasy.reactive.client.impl.ClientRequestContextImpl.getRestClientRequestContext()" because "requestContext" is null
        at com.example.CustomRestClientResponseFilter.filter(CustomRestClientResponseFilter.java:21)
        at org.jboss.resteasy.reactive.client.handlers.ClientResponseFilterRestHandler.handle(ClientResponseFilterRestHandler.java:21)
        ... 15 more

This comment was marked as resolved.

@rober710 rober710 changed the title Fix NPE in ClientResponseFilterRestHandler. Fix NPE in ClientResponseFilterRestHandler Dec 19, 2024
@rober710
Copy link
Contributor Author

Quick question: to avoid having to fix every handler, isn't it better to call requestContext.getOrCreateClientRequestContext() here?

@rober710 rober710 force-pushed the fix-npe-rest-handler branch from 68c7f96 to ecd59b4 Compare December 19, 2024 14:29
@geoand
Copy link
Contributor

geoand commented Dec 19, 2024

Thanks for the PR!

avoid having to fix every handler, isn't it better to call requestContext.getOrCreateClientRequestContext() here?

That doesn't look like a natural place to do such a thing

Copy link

quarkus-bot bot commented Dec 19, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit ecd59b4.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@geoand geoand merged commit 00b8eb2 into quarkusio:main Dec 19, 2024
32 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Dec 19, 2024
@rober710 rober710 deleted the fix-npe-rest-handler branch December 19, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants