From 1d2bca87e911c73f0754855ad9ebc93ec9bbfb2c Mon Sep 17 00:00:00 2001 From: Martin Kleppmann Date: Sat, 2 Jun 2012 01:06:47 -0700 Subject: [PATCH] Fix NPE in listing read-only store versions ReadOnlyUtils.getVersionDirs returns null if storeDir does not exist. I don't yet know how it could get into a state where it thinks the directory doesn't exist, but the NPE is obscuring the actual cause, so I'm fixing that first. --- src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java b/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java index 40f229c275..71faa3e40a 100644 --- a/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java +++ b/src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java @@ -350,7 +350,7 @@ public void swapFiles(String newStoreDirectory) { */ private void deleteBackups() { File[] storeDirList = ReadOnlyUtils.getVersionDirs(storeDir, 0L, currentVersionId); - if(storeDirList.length > (numBackups + 1)) { + if(storeDirList != null && storeDirList.length > (numBackups + 1)) { // delete ALL old directories asynchronously File[] extraBackups = ReadOnlyUtils.findKthVersionedDir(storeDirList, 0, @@ -424,7 +424,7 @@ public void rollback(File rollbackToDir) { throw new VoldemortException("Cannot parse version id"); File[] backUpDirs = ReadOnlyUtils.getVersionDirs(storeDir, versionId, Long.MAX_VALUE); - if(backUpDirs.length <= 1) { + if(backUpDirs == null || backUpDirs.length <= 1) { logger.warn("No rollback performed since there are no back-up directories"); return; }