398467 Servlet 3.1 Non Blocking IO
completed removal of HttpOutput.closeIfAllContentWritten
This commit is contained in:
parent
6f0195e0de
commit
c961d65697
|
@ -48,9 +48,13 @@ public class EncodingHttpWriter extends HttpWriter
|
|||
@Override
|
||||
public void write (char[] s,int offset, int length) throws IOException
|
||||
{
|
||||
HttpOutput out = _out;
|
||||
if (length==0)
|
||||
_out.closeIfAllContentWritten();
|
||||
|
||||
{
|
||||
if (_out.isAllContentWritten())
|
||||
close();
|
||||
}
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
_bytes.reset();
|
||||
|
@ -58,7 +62,7 @@ public class EncodingHttpWriter extends HttpWriter
|
|||
|
||||
_converter.write(s, offset, chars);
|
||||
_converter.flush();
|
||||
_bytes.writeTo(_out);
|
||||
_bytes.writeTo(out);
|
||||
length-=chars;
|
||||
offset+=chars;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
@ -154,15 +153,15 @@ public class HttpOutput extends ServletOutputStream
|
|||
_channel.write(BufferUtil.EMPTY_BUFFER, false);
|
||||
}
|
||||
|
||||
public boolean closeIfAllContentWritten() throws IOException
|
||||
public boolean isAllContentWritten()
|
||||
{
|
||||
Response response=_channel.getResponse();
|
||||
if (response.isAllContentWritten(_written))
|
||||
{
|
||||
response.closeOutput();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return response.isAllContentWritten(_written);
|
||||
}
|
||||
|
||||
public void closeOutput() throws IOException
|
||||
{
|
||||
_channel.getResponse().closeOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -231,12 +230,16 @@ public class HttpOutput extends ServletOutputStream
|
|||
BufferUtil.append(_aggregate, (byte)b);
|
||||
_written++;
|
||||
|
||||
boolean complete=_channel.getResponse().isAllContentWritten(_written);
|
||||
|
||||
// Check if all written or full
|
||||
if (!closeIfAllContentWritten() && BufferUtil.isFull(_aggregate))
|
||||
if (complete || BufferUtil.isFull(_aggregate))
|
||||
{
|
||||
BlockingCallback callback = _channel.getWriteBlockingCallback();
|
||||
_channel.write(_aggregate, false, callback);
|
||||
callback.block();
|
||||
if (complete)
|
||||
closed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,10 @@ public class Iso88591HttpWriter extends HttpWriter
|
|||
{
|
||||
HttpOutput out = _out;
|
||||
if (length==0)
|
||||
out.closeIfAllContentWritten();
|
||||
{
|
||||
if (_out.isAllContentWritten())
|
||||
close();
|
||||
}
|
||||
|
||||
if (length==1)
|
||||
{
|
||||
|
|
|
@ -44,8 +44,11 @@ public class Utf8HttpWriter extends HttpWriter
|
|||
{
|
||||
HttpOutput out = _out;
|
||||
if (length==0)
|
||||
out.closeIfAllContentWritten();
|
||||
|
||||
{
|
||||
if (_out.isAllContentWritten())
|
||||
close();
|
||||
}
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
_bytes.reset();
|
||||
|
|
Loading…
Reference in New Issue