From 1fee1ef74ed8ac515c19a7f8eebd16f41a37b7b6 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 4 Jul 2013 10:58:37 +0200 Subject: [PATCH] [#1520] Release previous set buffer when setting a new data source --- .../codec/http/multipart/AbstractMemoryHttpData.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java index b6aa0ccdf4..4e21627c02 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java @@ -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;