Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fix for npe in HTCache cleaning process

orbiter441e9c861e17
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index 51937f358..a0a487901 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -401,15 +401,15 @@ public final class plasmaHTCache {
return false;
}
- private static boolean deleteFileandDirs(File obj, String msg) {
- if (deleteFile(obj)) {
- log.logInfo("DELETED " + msg + " CACHE: " + obj.toString());
- obj = obj.getParentFile();
+ private static boolean deleteFileandDirs(File path, String msg) {
+ if (deleteFile(path)) {
+ log.logInfo("DELETED " + msg + " CACHE: " + path.toString());
+ path = path.getParentFile(); // returns null if the path does not have a parent
// If the has been emptied, remove it
- // Loop as long as we produce empty driectoriers, but stop at HTCACHE
- while ((!(obj.equals(cachePath))) && (obj.isDirectory()) && (obj.list().length == 0)) {
- if (obj.delete()) if (log.isFine()) log.logFine("DELETED EMPTY DIRECTORY : " + obj.toString());
- obj = obj.getParentFile();
+ // Loop as long as we produce empty directories, but stop at HTCACHE
+ while (path != null && !(path.equals(cachePath)) && path.isDirectory() && path.list().length == 0) { // NPE
+ if (path.delete()) if (log.isFine()) log.logFine("DELETED EMPTY DIRECTORY : " + path.toString());
+ path = path.getParentFile(); // returns null if the path does not have a parent
}
return true;
}