406768 Close inputstream and channels for 0 length resources
This commit is contained in:
parent
9d32209576
commit
68b9115e07
|
@ -268,7 +268,7 @@ public class HttpOutput extends ServletOutputStream
|
||||||
{
|
{
|
||||||
Resource resource = (Resource)content;
|
Resource resource = (Resource)content;
|
||||||
_channel.getResponse().getHttpFields().putDateField(HttpHeader.LAST_MODIFIED, resource.lastModified());
|
_channel.getResponse().getHttpFields().putDateField(HttpHeader.LAST_MODIFIED, resource.lastModified());
|
||||||
content = resource.getInputStream();
|
content=resource.getInputStream(); // Closed below
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process content.
|
// Process content.
|
||||||
|
@ -279,9 +279,8 @@ public class HttpOutput extends ServletOutputStream
|
||||||
}
|
}
|
||||||
else if (content instanceof ReadableByteChannel)
|
else if (content instanceof ReadableByteChannel)
|
||||||
{
|
{
|
||||||
ReadableByteChannel channel = (ReadableByteChannel)content;
|
|
||||||
ByteBuffer buffer = _channel.getByteBufferPool().acquire(getBufferSize(), CHANNEL_BUFFER_DIRECT);
|
ByteBuffer buffer = _channel.getByteBufferPool().acquire(getBufferSize(), CHANNEL_BUFFER_DIRECT);
|
||||||
try
|
try (ReadableByteChannel channel = (ReadableByteChannel)content;)
|
||||||
{
|
{
|
||||||
while(channel.isOpen())
|
while(channel.isOpen())
|
||||||
{
|
{
|
||||||
|
@ -301,12 +300,11 @@ public class HttpOutput extends ServletOutputStream
|
||||||
}
|
}
|
||||||
else if (content instanceof InputStream)
|
else if (content instanceof InputStream)
|
||||||
{
|
{
|
||||||
InputStream in = (InputStream)content;
|
|
||||||
ByteBuffer buffer = _channel.getByteBufferPool().acquire(getBufferSize(), STREAM_BUFFER_DIRECT);
|
ByteBuffer buffer = _channel.getByteBufferPool().acquire(getBufferSize(), STREAM_BUFFER_DIRECT);
|
||||||
byte[] array = buffer.array();
|
byte[] array = buffer.array();
|
||||||
int offset=buffer.arrayOffset();
|
int offset=buffer.arrayOffset();
|
||||||
int size=array.length-offset;
|
int size=array.length-offset;
|
||||||
try
|
try (InputStream in = (InputStream)content;)
|
||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue