From 0e98c370fd00492dc6973e017b9b7cc3315280be Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 20 Oct 2020 16:28:36 -0500 Subject: [PATCH] Issue #5480 - NPE protection on IO.delete(File) Signed-off-by: Joakim Erdfelt --- jetty-util/src/main/java/org/eclipse/jetty/util/IO.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java b/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java index 0ccd1ec969d3..7937481be620 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java @@ -361,10 +361,13 @@ public static String toString(Reader in) * This delete will recursively delete directories - BE CAREFUL * * @param file The file (or directory) to be deleted. - * @return true if anything was deleted. (note: this does not mean that all content in a directory was deleted) + * @return true if file was deleted, or directory referenced was deleted. + * false if file doesn't exist, or was null. */ public static boolean delete(File file) { + if (file == null) + return false; if (!file.exists()) return false; if (file.isDirectory())