[#1520] Release previous set buffer when setting a new data source

This commit is contained in:
Norman Maurer 2013-07-04 10:58:37 +02:00
parent 45d20d5c9f
commit 1fee1ef74e

View File

@ -53,6 +53,9 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
throw new IOException("Out of size: " + localsize + " > " + throw new IOException("Out of size: " + localsize + " > " +
definedSize); definedSize);
} }
if (byteBuf != null) {
byteBuf.release();
}
byteBuf = buffer; byteBuf = buffer;
size = localsize; size = localsize;
completed = true; completed = true;
@ -76,6 +79,9 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
if (definedSize > 0 && definedSize < size) { if (definedSize > 0 && definedSize < size) {
throw new IOException("Out of size: " + size + " > " + definedSize); throw new IOException("Out of size: " + size + " > " + definedSize);
} }
if (byteBuf != null) {
byteBuf.release();
}
byteBuf = buffer; byteBuf = buffer;
completed = true; completed = true;
} }
@ -133,6 +139,9 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
fileChannel.close(); fileChannel.close();
inputStream.close(); inputStream.close();
byteBuffer.flip(); byteBuffer.flip();
if (byteBuf != null) {
byteBuf.release();
}
byteBuf = wrappedBuffer(byteBuffer); byteBuf = wrappedBuffer(byteBuffer);
size = newsize; size = newsize;
completed = true; completed = true;