Skip to content

CompressionHandler randomly truncates output #15678

Description

@darnap

Jetty version(s)
12.1.12

Jetty Environment
ee10

HTTP version
HTTP 1.1

Java version/vendor (use: java -version)
25.0.1 Oracle Corporation

OS type/version
Windows 11 25H2

Description

When the compression handler is enabled, some responses seem to be truncated. This happens systematically for specific static files. Note that the output is correctly decompressed, but the file is incomplete. In some cases, the browser detects the lack of chunk data (NS_ERROR_NET_PARTIAL_TRANSFER on Firefox, for example).

This may be related to #15432 but happens also with zstd and gzip compression.

Strangely, this reliably occurs on some host machines and not on others.

From a debug analysis this seems to be caused by HttpOutput.complete() attempting to write a 0-length payload after the EncoderSink has already transitioned to the FINISHED state (having written the entire payload), which causes the IllegalStateException to be thrown.

Log fragment and stack trace follows:

15:04:50:817004|0248-00203:DEBUG|IteratingCallback - succeeded oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3145728,l=3166248,c=3166248,r=20520]={(function...__.Inpu<<<t}],title:[{type:_angular...ingURL=ngToolkit.js.map>>>},last=true]
15:04:50:817049|0287-00203:DEBUG|ConcurrentPool - released true oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=0,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=0,size=4,max=256,leaked=0,terminated=false]
15:04:50:817085|0259-00203:DEBUG|IteratingCallback - processing SCHEDULED oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3145728,l=3166248,c=3166248,r=20520]={(function...__.Inpu<<<t}],title:[{type:_angular...ingURL=ngToolkit.js.map>>>},last=true]
15:04:50:944434|0289-00203:DEBUG|ConcurrentPool - returning entry oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=1,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=1,size=4,max=256,leaked=0,terminated=false]
15:04:50:944497|0405-00203:DEBUG|ZstandardEncoderSink - encode() stateIn=CONTINUE, last=true, content=java.nio.DirectByteBuffer[pos=3166248 lim=3166248 cap=3166248], write=WriteRecord[last=false, output=java.nio.DirectByteBuffer[pos=0 lim=3018 cap=8192], callback=Callback.Completing@2f105552{NON_BLOCKING,org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink$$Lambda/0x0000000026deaed8@1d85a791}], stateNow=CONTINUE
15:04:50:944510|0302-00203:DEBUG|EncoderSink$EncodeBufferCallback - process() - write() WriteRecord[last=false, output=java.nio.DirectByteBuffer[pos=0 lim=3018 cap=8192], callback=Callback.Completing@2f105552{NON_BLOCKING,org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink$$Lambda/0x0000000026deaed8@1d85a791}]
15:04:50:944548|0246-00203:DEBUG|HttpOutput - write(array jn.HeapByteBuffer@4654c86c[p=0,l=3018,c=3018,r=3018]={<<<\x0e\xB3\x06\x8b_I\x95\x195B\x8a\xD4\xAbG\x11l\xB2\x8d\xE1Hu'\x01\x1e<...\xD3\x11\xAe\xDd\xAdV\x16\xE1\xCe\xF9\xB7\x01\xC8\xF9\xC1\xB40P\x1dy\xA6\xBb\x03>>>})
15:04:50:944570|0197-00203:DEBUG|HttpOutput - write(array) s=OPEN,api=BLOCKING,sc=false,e=null,wb=oeju.Blocker$Shared@50815322[c=null] aggregated !flush oeji.ArrayByteBufferPool$PooledBuffer@69d5d1cb[27594/32768,d=true,rc=1]

15:04:50:944585|0193-00203:DEBUG|IteratingCallback - succeeded oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:50:944690|0287-00203:DEBUG|ConcurrentPool - released true oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=0,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=0,size=4,max=256,leaked=0,terminated=false]
15:04:50:944712|0204-00203:DEBUG|IteratingCallback - processing SCHEDULED oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:51:214466|0289-00203:DEBUG|ConcurrentPool - returning entry oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=1,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=1,size=4,max=256,leaked=0,terminated=false]
15:04:51:214521|0287-00203:DEBUG|ConcurrentPool - released true oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=0,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=0,size=4,max=256,leaked=0,terminated=false]
15:04:51:415962|0289-00203:DEBUG|ConcurrentPool - returning entry oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=1,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=1,size=4,max=256,leaked=0,terminated=false]
15:04:51:416360|0402-00203:DEBUG|ZstandardEncoderSink - encode() stateIn=CONTINUE, last=true, content=java.nio.DirectByteBuffer[pos=3166248 lim=3166248 cap=3166248], write=WriteRecord[last=false, output=java.nio.DirectByteBuffer[pos=0 lim=3568 cap=8192], callback=Callback.Completing@138cbb10{NON_BLOCKING,org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink$$Lambda/0x0000000026d98ae0@3e9bc6f6}], stateNow=FLUSH
15:04:51:416384|0302-00203:DEBUG|EncoderSink$EncodeBufferCallback - process() - write() WriteRecord[last=false, output=java.nio.DirectByteBuffer[pos=0 lim=3568 cap=8192], callback=Callback.Completing@138cbb10{NON_BLOCKING,org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink$$Lambda/0x0000000026d98ae0@3e9bc6f6}]
15:04:51:416431|0227-00203:DEBUG|HttpOutput - write(array jn.HeapByteBuffer@e92479b[p=0,l=3568,c=3568,r=3568]={<<<mo\x00\xB63\xA2'\xB0Xu\x03\xD4\x87\xFc\xB5n\xCf\x14"F\x9d\xC8;\xB8\xB3...'\xB7/\xD0\x90p\x94.f\xC4\x82\x10\xC1\xE0\xE5Zj\x1c/\xD4;\xCb7>>>})
15:04:51:416454|0197-00203:DEBUG|HttpOutput - write(array) s=OPEN,api=BLOCKING,sc=false,e=null,wb=oeju.Blocker$Shared@50815322[c=null] aggregated !flush oeji.ArrayByteBufferPool$PooledBuffer@69d5d1cb[31162/32768,d=true,rc=1]
15:04:51:416471|0193-00203:DEBUG|IteratingCallback - succeeded oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:51:416493|0287-00203:DEBUG|ConcurrentPool - released true oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=0,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=0,size=4,max=256,leaked=0,terminated=false]
15:04:51:416506|0204-00203:DEBUG|IteratingCallback - processing SCHEDULED oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:51:816815|0289-00203:DEBUG|ConcurrentPool - returning entry oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=1,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=1,size=4,max=256,leaked=0,terminated=false]
15:04:52:440962|0398-00203:DEBUG|ZstandardEncoderSink - encode() stateIn=FLUSH, last=true, content=java.nio.DirectByteBuffer[pos=3166248 lim=3166248 cap=3166248], write=WriteRecord[last=true, output=java.nio.DirectByteBuffer[pos=0 lim=0 cap=8192], callback=Callback.Completing@6e65f98d{NON_BLOCKING,org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink$$Lambda/0x0000000026d9a208@18478b6a}], stateNow=FINISHED
15:04:52:441016|0298-00203:DEBUG|EncoderSink$EncodeBufferCallback - process() - write() WriteRecord[last=true, output=java.nio.DirectByteBuffer[pos=0 lim=0 cap=8192], callback=Callback.Completing@6e65f98d{NON_BLOCKING,org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink$$Lambda/0x0000000026d9a208@18478b6a}]
15:04:52:441184|0193-00203:DEBUG|IteratingCallback - succeeded oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:52:441251|0287-00203:DEBUG|ConcurrentPool - released true oeju.ConcurrentPool$ConcurrentEntry@458d3f6e{terminated=false,multiplex=0,pooled=oeji.ArrayByteBufferPool$PooledBuffer@6e74ef62[0/8192,d=true,rc=0]} for oeju.ConcurrentPool@3f935416[strategy=THREAD_ID,inUse=0,size=4,max=256,leaked=0,terminated=false]
15:04:52:441268|0204-00203:DEBUG|IteratingCallback - processing SCHEDULED oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:52:441304|0204-00203:DEBUG|IteratingCallback - processing SUCCEEDED oejc.EncoderSink$EncodeBufferCallback@7a82842c[content=jn.DirectByteBuffer@1482476d[p=3166248,l=3166248,c=3166248,r=0]={(function....js.map<<<>>>},last=true]
15:04:52:441340|0141-00203:DEBUG|ServletChannelState - complete oeje10s.ServletChannelState@27786c15{s=HANDLING rs=ASYNC os=OPEN is=IDLE awp=false se=false i=true al=0}
15:04:53:001424|0144-00203:DEBUG|ServletChannelState - unhandle oeje10s.ServletChannelState@27786c15{s=HANDLING rs=COMPLETE os=OPEN is=IDLE awp=false se=false i=true al=0}
15:04:53:001454|0165-00203:DEBUG|ServletChannelState - nextAction(false) COMPLETE oeje10s.ServletChannelState@27786c15{s=HANDLING rs=COMPLETING os=OPEN is=IDLE awp=false se=false i=false al=0}
15:04:53:001622|0275-00203:DEBUG|ServletChannel - action COMPLETE oeje10s.ServletChannel@1b55408d{s=oeje10s.ServletChannelState@27786c15{s=HANDLING rs=COMPLETING os=OPEN is=IDLE awp=false se=false i=false al=0},r=0,c=false/false,a=HANDLING,uri=http://xxx/app/ngToolkit.js,age=9312}
15:04:53:001740|0373-00203:DEBUG|HttpOutput - complete(Callback@64b96cf7{NON_BLOCKING, org.eclipse.jetty.ee10.servlet.ServletChannel$$Lambda/0x0000000026d9a8e0@25d1587c,org.eclipse.jetty.ee10.servlet.ServletChannel$$Lambda/0x0000000026d9ab10@1698b77}) s=CLOSING,api=BLOCKED,sc=false,e=null,wb=oeju.Blocker$Shared@788b42e2[c=null] s=false e=null, c=jn.HeapByteBuffer@6b469ebf[p=0,l=0,c=0,r=0]={<<<>>>}
15:04:54:136867|7674-00203:DEBUG|IteratingCallback - failed oejc.EncoderSink$EncodeBufferCallback@c265ba3[content=jn.HeapByteBuffer@6b469ebf[p=0,l=0,c=0,r=0]={<<<>>>},last=true]java.lang.IllegalStateException: Already released
	at org.eclipse.jetty.compression.zstandard.internal.ZstandardEncoderSink.encode(ZstandardEncoderSink.java:80)
	at org.eclipse.jetty.compression.EncoderSink$EncodeBufferCallback.process(EncoderSink.java:97)
	at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:374)
	at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:351)
	at org.eclipse.jetty.compression.EncoderSink.write(EncoderSink.java:39)
	at org.eclipse.jetty.compression.server.internal.CompressionResponse.write(CompressionResponse.java:192)
	at org.eclipse.jetty.ee10.servlet.HttpOutput.channelWrite(HttpOutput.java:238)
	at org.eclipse.jetty.ee10.servlet.HttpOutput.complete(HttpOutput.java:477)
	at org.eclipse.jetty.ee10.servlet.ServletContextResponse.completeOutput(ServletContextResponse.java:212)
	at org.eclipse.jetty.ee10.servlet.ServletChannel.handle(ServletChannel.java:606)
	at org.eclipse.jetty.ee10.servlet.ServletHandler.handle(ServletHandler.java:469)
	at org.eclipse.jetty.ee10.servlet.SessionHandler.handle(SessionHandler.java:719)
	at org.eclipse.jetty.compression.server.CompressionHandler.handle(CompressionHandler.java:343)
	at org.eclipse.jetty.server.Handler$Wrapper.handle(Handler.java:794)
	at org.eclipse.jetty.server.handler.CrossOriginHandler.handle(CrossOriginHandler.java:336)
	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1253)
	at org.eclipse.jetty.ee10.servlet.CrossContextDispatcher.forward(CrossContextDispatcher.java:268)

Activity

  1. added
    Bug
    on Aug 27, 2026
  2. self-assigned this
    on Sep 9, 2026
  3. moved this to 🏗 In progress in Jetty 12.1.14 FROZENon Sep 9, 2026
  4. lorban commented on Sep 9, 2026

    @lorban
    Contributor

    I can confirm this is a bug. I reproduced it and I think I identified it and came up with a fix: #15759

    I'd be glad if you could build that branch and report back the outcome. Update: the current patch breaks the servlet output stream in non-trivial ways, it's not yet ready for trial.

    Thanks for the report!

  5. added 2 commits that reference this issue on Sep 9, 2026
  6. lorban commented on Sep 11, 2026

    @lorban
    Contributor

    @darnap now #15759 is ready for review if you want to give it a try yourself and report back the outcome.

    Thanks!

  7. darnap commented on Sep 14, 2026

    @darnap
    Author

    @lorban I did a quick test and the issue no longer seems to occur with this fix. Thanks.

  8. moved this to 🏗 In progress in Jetty 12.0.40 FROZENon Sep 24, 2026
  9. added a commit that references this issue on Sep 25, 2026
    1159bd2
  10. moved this from 🏗 In progress to ✅ Done in Jetty 12.0.40 FROZENon Sep 25, 2026
  11. reopened this on Sep 25, 2026
  12. added a commit that references this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bug

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions