From 109abe1ba34534fc237e75a54c385ca682272396 Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Wed, 13 Oct 2021 16:35:48 +0800 Subject: [PATCH] potential NPE in PackageInternalsFinder (#1998) --- .../compiler/PackageInternalsFinder.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java b/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java index cc5d183e7..80fdf0597 100644 --- a/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java +++ b/memorycompiler/src/main/java/com/taobao/arthas/compiler/PackageInternalsFinder.java @@ -95,14 +95,16 @@ public class PackageInternalsFinder { List result = new ArrayList(); File[] childFiles = directory.listFiles(); - for (File childFile : childFiles) { - if (childFile.isFile()) { - // We only want the .class files. - if (childFile.getName().endsWith(CLASS_FILE_EXTENSION)) { - String binaryName = packageName + "." + childFile.getName(); - binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); - - result.add(new CustomJavaFileObject(binaryName, childFile.toURI())); + if (childFiles != null) { + for (File childFile : childFiles) { + if (childFile.isFile()) { + // We only want the .class files. + if (childFile.getName().endsWith(CLASS_FILE_EXTENSION)) { + String binaryName = packageName + "." + childFile.getName(); + binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); + + result.add(new CustomJavaFileObject(binaryName, childFile.toURI())); + } } } }