From b8df8dead373fd43ca184568a606d90389dff70e Mon Sep 17 00:00:00 2001 From: Jiri Danek Date: Thu, 14 Feb 2019 15:50:03 +0100 Subject: [PATCH] NO-JIRA Fix a "Dereference null return value" Coverity Scan warning The value checked for null was not the one that was subsequently used. --- .../apache/activemq/artemis/utils/SpawnedVMSupport.java | 2 +- .../apache/activemq/artemis/component/WebTmpCleaner.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SpawnedVMSupport.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SpawnedVMSupport.java index 82724c1811..d99871567d 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SpawnedVMSupport.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SpawnedVMSupport.java @@ -146,7 +146,7 @@ public class SpawnedVMSupport { if (files == null) { return getClassPath(); } else { - for (File f : libfolder.listFiles()) { + for (File f : files) { if (f.getName().endsWith(".jar") || f.getName().endsWith(".zip")) { if (!empty) { stringBuilder.append(File.pathSeparator); diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebTmpCleaner.java b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebTmpCleaner.java index 0bc0b67456..478a0120b2 100644 --- a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebTmpCleaner.java +++ b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebTmpCleaner.java @@ -65,9 +65,11 @@ public class WebTmpCleaner { public static final void deleteFolder(final File file) { if (file.isDirectory()) { String[] files = file.list(); - for (String path : files) { - File f = new File(file, path); - deleteFolder(f); + if (files != null) { + for (String path : files) { + File f = new File(file, path); + deleteFolder(f); + } } } file.delete();