<p dir="ltr">Thanks for the tips. My local flush was actually based on org.xnio.conduits.BufferedStreamSinkConduit including a terminated flag, except that i was also passing terminateWrites() on to the delegate. I&#39;ll try it with writeFinal() instead.</p>
<p dir="ltr">Jeff</p>
<div class="gmail_quote">On 03/11/2014 9:11 PM, &quot;Stuart Douglas&quot; &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">org.xnio.conduits.BufferedStreamSinkConduit is probably a good example, although it does not use writeFinal().<br>
<br>
Stuart<br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Stuart Douglas&quot; &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt; To: &quot;Jeff Williams&quot; &lt;<a href="mailto:jeffw@wherethebitsroam.com">jeffw@wherethebitsroam.com</a>&gt;<br>
&gt; Cc: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; Sent: Tuesday, 4 November, 2014 7:10:53 AM<br>
&gt; Subject: Re: [undertow-dev] AbstractFixedLengthStreamSinkConduit<br>
&gt;<br>
&gt; You need to not pass on the terminateWrites() call to the delegate until your<br>
&gt; have written all your data.<br>
&gt;<br>
&gt; Once terminateWrites is called on your channel set some kind of boolean flag<br>
&gt; to indicate that this is shutdown, and then when the user calls flush()<br>
&gt; write out the buffer (using writeFinal for best performance). If you are not<br>
&gt; using writeFinal() then you need to call terminateWrites() once you succeed<br>
&gt; in flushing, and then pass further flush calls to the delegate.<br>
&gt;<br>
&gt; Stuart<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; &gt; From: &quot;Jeff Williams&quot; &lt;<a href="mailto:jeffw@wherethebitsroam.com">jeffw@wherethebitsroam.com</a>&gt;<br>
&gt; &gt; To: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; &gt; Sent: Monday, 3 November, 2014 11:48:10 PM<br>
&gt; &gt; Subject: [undertow-dev] AbstractFixedLengthStreamSinkConduit<br>
&gt; &gt;<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; I have written a StreamSinkConduit which buffers content in a pooled<br>
&gt; &gt; buffer.<br>
&gt; &gt; I am having an issue with AbstractFixedLengthStreamSinkConduit throwing a<br>
&gt; &gt; FixedLengthUnderflowException exception.<br>
&gt; &gt;<br>
&gt; &gt; If I have content left in my buffer which I have not yet been able to write<br>
&gt; &gt; to the next conduit when terminateWrites is called, the exception is<br>
&gt; &gt; thrown.<br>
&gt; &gt; Even though this content would have been written in the subsequent call to<br>
&gt; &gt; flush. Shouldn&#39;t the bytes remaining be checked after a successful flush<br>
&gt; &gt; rather than in terminateWrites? Or am I missing something?<br>
&gt; &gt;<br>
&gt; &gt; For the time being I am flushing my local buffer in terminateWrites, but<br>
&gt; &gt; this<br>
&gt; &gt; seems wrong!<br>
&gt; &gt;<br>
&gt; &gt; Jeff<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; undertow-dev mailing list<br>
&gt; &gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br>
</blockquote></div>