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