[undertow-dev] StreamSinkChannel - repeatable writes error

Stuart Douglas sdouglas at redhat.com
Tue Dec 11 17:50:27 EST 2012


Hmm, looks like I actually fixed the StreamSourceChannel, and the same 
bug exists in the StreamSinkChannel.

For now I have moved these into undertow and fixed the problem, and 
added some tests. I have also removed the volatile writes that attempted 
to provide some level of protection against multi-threaded channel 
access. The handler contract does not allow for concurrent channel 
access, and the volatile writes just slow things down.

Stuart

Matej Lazar wrote:
> I updatetd to XNIO 3.1.0.Beta7 and latest Undertow master.
>
> I still have an exception
>
> Dec 11, 2012 7:02:02 PM io.undertow.util.WorkerDispatcher$1 run
> ERROR: UNDERTOW005001: An exception occurred processing the request
> org.xnio.channels.FixedLengthUnderflowException: 65536 bytes remaining
> 	at org.xnio.channels.FixedLengthStreamSinkChannel.shutdownWrites(FixedLengthStreamSinkChannel.java:291)
> 	at ceylon.net.httpd.internal.HttpResponseImpl.responseDone(HttpResponseImpl.ceylon:69)
> 	at ceylon.net.httpd.internal.CeylonRequestHandler$AsyncInvoker$1completionHandler_.handleComplete(CeylonRequestHandler.ceylon:65)
> 	at ceylon.net.httpd.endpoints.StaticFileEndpoint.service(StaticFileEndpoint.ceylon:69)
> 	at ceylon.net.httpd.internal.CeylonRequestHandler$AsyncInvoker.run(CeylonRequestHandler.ceylon:69)
> 	at io.undertow.util.WorkerDispatcher$1.run(WorkerDispatcher.java:53)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:722)
>
>
> Matej.
>
>
>
> On 23/10/12 00:49, Stuart Douglas wrote:
>> This should be fixed in the XNIO upstream:
>>
>> https://github.com/xnio/xnio/commit/5a1ed9dff29455d78bc9beb50c6e448e1bbb6ef9
>>
>> David, would we be able to get another XNIO release soonish?
>>
>> Stuart
>>
>> Matej Lazar wrote:
>>> Hi, I'm writing an http server for Ceylon on top of undertow.
>>>
>>> All bytes are written to response and successfully transferred, but exception bellow occurs when shutdownWrites is called.
>>>
>>> Stepping through a "write" method of FixedLengthStreamSinkChannel, looks like "state" is not updated correctly, it is always subtracted only for are number of bytes written in one loop.
>>>
>>> Am I missing something or is it a bug ?
>>>
>>> byte array size is 6919638, usually there are 147456 bytes written to a response in a loop
>>>
>>> My code for writing bytes to response ... not quite Java, but readable ;)
>>>
>>>       shared actual void writeBytes(Array<Integer>   bytes) {
>>>           //ByteBuffer.wrap
>>>      value bb = wrapByteBuffer(bytes);
>>>      value response = getResponse();
>>>
>>>      variable Integer remaining := bytes.size;
>>>           while (remaining>   0) {
>>>          variable Integer written := 0;
>>>          while((written := response.write(bb))>   0) {
>>>              remaining -= written;
>>>              try {
>>>                  response.awaitWritable();
>>>              } catch(JIOException e) {
>>>                  //TODO
>>>                  print(e);
>>>              }
>>>          }
>>>      }
>>>       }
>>>
>>>
>>> Exception in thread "XNIO-1 task-2" java.lang.Error: org.xnio.channels.FixedLengthUnderflowException: 6815744 bytes remaining
>>>      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
>>>      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>>>      at java.lang.Thread.run(Thread.java:722)
>>> Caused by: org.xnio.channels.FixedLengthUnderflowException: 6815744 bytes remaining
>>>      at org.xnio.channels.FixedLengthStreamSinkChannel.shutdownWrites(FixedLengthStreamSinkChannel.java:291)
>>>      at ceylon.net.httpd.internal.HttpResponseImpl.responseDone(HttpResponseImpl.ceylon:71)
>>>      at ceylon.net.httpd.internal.CeylonRequestHandler$AsyncInvoker$1completionHandler_.handleComplete(CeylonRequestHandler.ceylon:56)
>>>      at ceylon.net.httpd.endpoints.StaticFileEndpoint.service(StaticFileEndpoint.ceylon:50)
>>>      at ceylon.net.httpd.internal.CeylonRequestHandler$AsyncInvoker.run(CeylonRequestHandler.ceylon:60)
>>>      at io.undertow.util.WorkerDispatcher$1.run(WorkerDispatcher.java:49)
>>>      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>>>      ... 2 more
>>>
>>>
>>> Thanks,
>>> Matej.
>>> _______________________________________________
>>> undertow-dev mailing list
>>> undertow-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>


More information about the undertow-dev mailing list