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

NPE in HttpReceiver.responseContentAvailable() #12122

Closed
sbordet opened this issue Aug 1, 2024 · 1 comment · Fixed by #12123
Closed

NPE in HttpReceiver.responseContentAvailable() #12122

sbordet opened this issue Aug 1, 2024 · 1 comment · Fixed by #12123
Labels
Bug For general bugs on Jetty side Sponsored This issue affects a user with a commercial support agreement

Comments

@sbordet
Copy link
Contributor

sbordet commented Aug 1, 2024

Jetty version(s)
12

Description

2024-07-29T20:27:41.8354855Z 2024-07-29T19:52:43.928Z	WARN	http-client-scheduler-512	org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy	Task run failed
2024-07-29T20:27:41.8355422Z java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.client.transport.HttpReceiver$NotifiableContentSource.onDataAvailable()" because "this.contentSource" is null
2024-07-29T20:27:41.8355750Z 	at org.eclipse.jetty.client.transport.HttpReceiver.responseContentAvailable(HttpReceiver.java:325)
2024-07-29T20:27:41.8356147Z 	at org.eclipse.jetty.http2.client.transport.internal.HttpReceiverOverHTTP2.lambda$new$0(HttpReceiverOverHTTP2.java:53)
2024-07-29T20:27:41.8356370Z 	at org.eclipse.jetty.util.thread.Invocable$ReadyTask.run(Invocable.java:105)
2024-07-29T20:27:41.8356731Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:478)
2024-07-29T20:27:41.8357793Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:426)
2024-07-29T20:27:41.8358221Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
2024-07-29T20:27:41.8358723Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:195)
2024-07-29T20:27:41.8358949Z 	at org.eclipse.jetty.http2.HTTP2Connection.produce(HTTP2Connection.java:210)
2024-07-29T20:27:41.8359186Z 	at org.eclipse.jetty.http2.HTTP2Connection.onFillable(HTTP2Connection.java:157)
2024-07-29T20:27:41.8359470Z 	at org.eclipse.jetty.http2.HTTP2Connection$FillableCallback.succeeded(HTTP2Connection.java:442)
2024-07-29T20:27:41.8359659Z 	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:99)
2024-07-29T20:27:41.8359936Z 	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
2024-07-29T20:27:41.8360287Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:478)
2024-07-29T20:27:41.8360671Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:441)
2024-07-29T20:27:41.8361206Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
2024-07-29T20:27:41.8361544Z 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:201)
2024-07-29T20:27:41.8361869Z 	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:311)
2024-07-29T20:27:41.8362311Z 	at org.eclipse.jetty.util.thread.MonitoredQueuedThreadPool$1.run(MonitoredQueuedThreadPool.java:73)
2024-07-29T20:27:41.8362557Z 	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:979)
2024-07-29T20:27:41.8362835Z 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1209)
2024-07-29T20:27:41.8363097Z 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1164)
2024-07-29T20:27:41.8363240Z 	at java.base/java.lang.Thread.run(Thread.java:1570)
@sbordet sbordet added Bug For general bugs on Jetty side Sponsored This issue affects a user with a commercial support agreement labels Aug 1, 2024
@sbordet
Copy link
Contributor Author

sbordet commented Aug 1, 2024

This seems to be caused by a concurrent interaction between a failure, that would null out the contentSource field, and another thread trying to deliver the "data available" event.

sbordet added a commit that referenced this issue Aug 1, 2024
Now also the HttpReceiver.responseContentAvailable() is serialized, so that the access to `this.contentSource` is serialized with failure, and protected by a call to `exchange.isResponseCompleteOrTerminated()`.

Before, it was possible that a thread failed the response, nulling out `this.contentSource`, while another thread was just about to call `responseContentAvailable()` -- this was the case for HTTP/2 in particular, where content is notified asynchronously, rather than being created by a call to `ContentSource.read()`.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet closed this as completed in d0ea445 Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side Sponsored This issue affects a user with a commercial support agreement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant