419350 Do not borrow space from passed arrays

This commit is contained in:
Greg Wilkins 2013-10-28 10:14:12 +11:00
parent de75b82f99
commit 960c03b8ac
1 changed files with 5 additions and 2 deletions

View File

@ -300,12 +300,14 @@ public class HttpOutput extends ServletOutputStream
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** Blocking send of content. /** Blocking send of content.
* @param content The content to send * @param content The content to send.
* @throws IOException * @throws IOException
*/ */
public void sendContent(ByteBuffer content) throws IOException public void sendContent(ByteBuffer content) throws IOException
{ {
final BlockingCallback callback =_channel.getWriteBlockingCallback(); final BlockingCallback callback =_channel.getWriteBlockingCallback();
if (content.hasArray()&&content.limit()<content.capacity())
content=content.asReadOnlyBuffer();
_channel.write(content,true,callback); _channel.write(content,true,callback);
callback.block(); callback.block();
} }
@ -347,7 +349,6 @@ public class HttpOutput extends ServletOutputStream
callback.block(); callback.block();
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** Asynchronous send of content. /** Asynchronous send of content.
* @param content The content to send * @param content The content to send
@ -355,6 +356,8 @@ public class HttpOutput extends ServletOutputStream
*/ */
public void sendContent(ByteBuffer content, final Callback callback) public void sendContent(ByteBuffer content, final Callback callback)
{ {
if (content.hasArray()&&content.limit()<content.capacity())
content=content.asReadOnlyBuffer();
_channel.write(content,true,new Callback() _channel.write(content,true,new Callback()
{ {
@Override @Override