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 ResponseListeners content notification #10726

Closed
sbordet opened this issue Oct 12, 2023 · 2 comments · Fixed by #10730
Closed

NPE in ResponseListeners content notification #10726

sbordet opened this issue Oct 12, 2023 · 2 comments · Fixed by #10730
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@sbordet
Copy link
Contributor

sbordet commented Oct 12, 2023

Jetty version(s)
12+

Description
Reported in jetty-project/jetty-reactive-httpclient#296.

This probably happens with Transfer-Encoding: chunked, when there is data to read, but it is only the chunk metadata, as in:

HTTP/1.1 200 OK
Transfer-Encoding: chunked

10

In this case, there will be a wakeup of the demand callback because there is data, but calling response.read() would yield null.

This case is not covered in the case of multiple response listeners in ResponseListeners.

[HttpClient@1623b78d-37] WARN org.eclipse.jetty.util.thread.SerializedInvoker - Serialized invocation error
java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.io.Content$Chunk.hasRemaining()" because "chunk" is null
	at org.eclipse.jetty.client.transport.ResponseListeners$ContentSourceDemultiplexer$ContentSource.onChunk(ResponseListeners.java:605)
	at org.eclipse.jetty.client.transport.ResponseListeners$ContentSourceDemultiplexer.onDemandCallback(ResponseListeners.java:492)
	at org.eclipse.jetty.util.thread.SerializedInvoker$Link.run(SerializedInvoker.java:191)
	at org.eclipse.jetty.util.thread.SerializedInvoker.run(SerializedInvoker.java:117)
	at org.eclipse.jetty.client.transport.HttpReceiver$ContentSource.invokeDemandCallback(HttpReceiver.java:722)
	at org.eclipse.jetty.client.transport.HttpReceiver$ContentSource.onDataAvailable(HttpReceiver.java:661)
	at org.eclipse.jetty.client.transport.HttpReceiver.responseContentAvailable(HttpReceiver.java:303)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:82)
	at org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:90)
	at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:194)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
	at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.onFillable(SslConnection.java:554)
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:373)
	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:146)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:478)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:441)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:201)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:410)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
	at java.base/java.lang.Thread.run(Thread.java:1623)
@sbordet sbordet added the Bug For general bugs on Jetty side label Oct 12, 2023
lorban added a commit that referenced this issue Oct 13, 2023
…he original source spuriously calls demand()

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban linked a pull request Oct 13, 2023 that will close this issue
@lorban lorban moved this to 🏗 In progress in Jetty 12.0.3 - FROZEN Oct 13, 2023
lorban added a commit that referenced this issue Oct 13, 2023
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
lorban added a commit that referenced this issue Oct 17, 2023
* #10726 fix NPE in ResponseListeners when demultiplexing is used and the original source spuriously calls demand()

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban closed this as completed Oct 17, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.3 - FROZEN Oct 17, 2023
@olenagerasimova
Copy link

Hi again, the problem does not seem completely fixed, jetty 12.0.3 fails with

java.lang.IllegalStateException
at org.eclipse.jetty.client.transport.ResponseListeners$ContentSourceDemultiplexer$ContentSource.demand(ResponseListeners.java:665)
at org.eclipse.jetty.reactive.client.internal.ResponseListenerProcessor$ContentPublisher.read(ResponseListenerProcessor.java:197)
at org.eclipse.jetty.reactive.client.internal.ResponseListenerProcessor$ContentPublisher.run(ResponseListenerProcessor.java:181)
at org.eclipse.jetty.reactive.client.internal.QueuedSinglePublisher.tryProduce(QueuedSinglePublisher.java:70)
at org.eclipse.jetty.reactive.client.internal.ResponseListenerProcessor$ContentPublisher.onRequest(ResponseListenerProcessor.java:174)
at org.eclipse.jetty.reactive.client.internal.AbstractSinglePublisher.request(AbstractSinglePublisher.java:90)

I've got java 17 application running inside docker container and performing some requests to maven-central. If this same application is running locally (not inside container), no problems occur.

@lorban
Copy link
Contributor

lorban commented Nov 1, 2023

@olenagerasimova This seems to be caused by a different problem. I tried running the reproducer you included in jetty-project/jetty-reactive-httpclient#296 and it passes with jetty-reactive-httpclient:4.0.1.

You should open a new jetty-reactive-httpclient issue with a new reproducer if possible.

Thanks!

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
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants