defense against NPE

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1156201 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2011-08-10 14:49:03 +00:00
parent 8c83a10317
commit 9c1d10c4e9
1 changed files with 12 additions and 4 deletions

View File

@ -403,12 +403,20 @@ public class CoreAdminHandler extends RequestHandlerBase {
@Override
public void postClose(SolrCore core) {
File dataDir = new File(core.getIndexDir());
for (File file : dataDir.listFiles()) {
if (!file.delete()) {
log.error(file.getAbsolutePath() + " could not be deleted on core unload");
File[] files = dataDir.listFiles();
if (files != null) {
for (File file : files) {
if (!file.delete()) {
log.error(file.getAbsolutePath()
+ " could not be deleted on core unload");
}
}
if (!dataDir.delete()) log.error(dataDir.getAbsolutePath()
+ " could not be deleted on core unload");
} else {
log.error(dataDir.getAbsolutePath()
+ " could not be deleted on core unload");
}
if (!dataDir.delete()) log.error(dataDir.getAbsolutePath() + " could not be deleted on core unload");
}
});
}