From da5da8e212727991eaaad8f06cce108a3d025471 Mon Sep 17 00:00:00 2001 From: Frederic Bregier Date: Mon, 20 Jan 2014 16:43:55 +0100 Subject: [PATCH] Fix try to delete file while it does not exist anymore (see #2102 and #1713) in reference to this issue --- .../handler/codec/http/multipart/AbstractDiskHttpData.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java index 216c67b7d6..4d50588cca 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java @@ -226,9 +226,10 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData { @Override public void delete() { if (! isRenamed) { - if (file != null) { + if (file != null && file.exists()) { file.delete(); } + file = null; } } @@ -308,6 +309,9 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData { if (dest == null) { throw new NullPointerException("dest"); } + if (file == null) { + throw new IOException("No file defined so cannot be renamed"); + } if (!file.renameTo(dest)) { // must copy FileInputStream inputStream = new FileInputStream(file);