You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HttpFields$Mutable.computeField() contract explicitly specifies that if the computeFn returns null, this means the field should be removed. Unfortunately, the default implementation of computeField() calls put() which incorrectly calls Wrapper.onAddField() with a null value.
When the protocol is HTTP 1.0, ResponseUtils.ensureNotPersistent() uses computeField() to remove the connection header, so that triggers the following exception:
java.lang.IllegalStateException: java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.http.HttpField.getHeader()" because "field" is null
at org.eclipse.jetty.ee10.servlet.ServletChannelState.onError(ServletChannelState.java:874)
at org.eclipse.jetty.ee10.servlet.ServletChannel.handleException(ServletChannel.java:667)
at org.eclipse.jetty.ee10.servlet.ServletChannel.handle(ServletChannel.java:584)
at org.eclipse.jetty.ee10.servlet.AsyncContentProducer.lambda$isReady$0(AsyncContentProducer.java:260)
at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.run(ContextHandler.java:1298)
at org.eclipse.jetty.server.handler.ContextRequest$OnContextDemand.run(ContextRequest.java:74)
at org.eclipse.jetty.util.thread.SerializedInvoker$Link.run(SerializedInvoker.java:191)
at org.eclipse.jetty.server.internal.HttpConnection$DemandContentCallback.succeeded(HttpConnection.java:679)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:99)
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:311)
at org.eclipse.jetty.util.thread.MonitoredQueuedThreadPool$1.run(MonitoredQueuedThreadPool.java:73)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:979)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1209)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1164)
at java.base/java.lang.Thread.run(Thread.java:1570)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.http.HttpField.getHeader()" because "field" is null
at org.eclipse.jetty.ee10.servlet.ServletContextResponse$HttpFieldsWrapper.onAddField(ServletContextResponse.java:567)
at org.eclipse.jetty.http.HttpFields$Mutable$Wrapper.put(HttpFields.java:1678)
at org.eclipse.jetty.http.HttpFields$Mutable.computeField(HttpFields.java:1372)
at org.eclipse.jetty.server.ResponseUtils.ensureNotPersistent(ResponseUtils.java:40)
at org.eclipse.jetty.server.ResponseUtils.ensureConsumeAvailableOrNotPersistent(ResponseUtils.java:31)
at org.eclipse.jetty.ee10.servlet.ServletChannel.handle(ServletChannel.java:554)
... 17 more
The text was updated successfully, but these errors were encountered:
lorban
added
Bug
For general bugs on Jetty side
Sponsored
This issue affects a user with a commercial support agreement
labels
Apr 23, 2024
lorban
changed the title
NPE thrown by HttpFields$Mutable.computeField() when null is returnedHttpFields$Mutable$Wrapper.computeField() incorrectly calls onAddField() when null is returned by computeFnApr 23, 2024
* #11687 make HttpFields.Mutable.Wrapper.computeField() call onRemoveField() and remove the field when null is returned by computeFn
* #11687 replace IAE with NPE
* #11687 replace collect(Collectors.toList()) with toList()
---------
Signed-off-by: Ludovic Orban <[email protected]>
Jetty version(s)
12.0.8
Jetty Environment
ee10
Description
The
HttpFields$Mutable.computeField()
contract explicitly specifies that if thecomputeFn
returns null, this means the field should be removed. Unfortunately, the default implementation ofcomputeField()
callsput()
which incorrectly callsWrapper.onAddField()
with a null value.When the protocol is HTTP 1.0,
ResponseUtils.ensureNotPersistent()
usescomputeField()
to remove the connection header, so that triggers the following exception:The text was updated successfully, but these errors were encountered: