Skip to content

Commit e85ae72

Browse files
author
Norman Maurer
committed
Set the destroyed flag at the correct time and fix a the httpupload example to release all resources
1 parent 10097bf commit e85ae72

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,9 +1204,9 @@ protected InterfaceHttpData getFileUpload(String delimiter) throws ErrorDataDeco
12041204
*/
12051205
public void destroy() {
12061206
checkDestroyed();
1207+
cleanFiles();
12071208
destroyed = true;
12081209

1209-
cleanFiles();
12101210
if (undecodedChunk != null && undecodedChunk.refCnt() > 0) {
12111211
undecodedChunk.release();
12121212
undecodedChunk = null;

example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ private void readHttpDataChunkByChunk() {
216216
while (decoder.hasNext()) {
217217
InterfaceHttpData data = decoder.next();
218218
if (data != null) {
219-
// new value
220-
writeHttpData(data);
219+
try {
220+
// new value
221+
writeHttpData(data);
222+
} finally {
223+
data.release();
224+
}
221225
}
222226
}
223227
} catch (EndOfDataDecoderException e1) {
@@ -275,7 +279,6 @@ private void writeHttpData(InterfaceHttpData data) {
275279
}
276280
}
277281
}
278-
//BufUtil.release(data);
279282
}
280283

281284
private void writeResponse(Channel channel) {

0 commit comments

Comments
 (0)