【发布时间】:2020-05-05 19:49:14
【问题描述】:
以下代码的第 5 行被 findbugs 发现为一个错误:
由于调用的返回值,com.xyz.common.CommonUtils.FolderNotEmpty(String) 中可能存在空指针取消引用 方法[麻烦(13),正常置信度]
public static boolean FolderNotEmpty(String path) {
boolean flag = false;
File f = new File(path);
if (f.isDirectory()) {
if (f.listFiles().length > 0) {
flag = true;
LOGGER.info("Folder - " + path + " is not empty.");
} else {
LOGGER.info("Folder - " + path + " is empty.");
}
} else {
LOGGER.warn("The given path is not a directory - " + path);
}
return flag;
}
【问题讨论】: