Skip to content

Commit

Permalink
0001794: Fix null pointer on busy system during staging area clean
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jul 4, 2014
1 parent 877744c commit 511a77f
Showing 1 changed file with 23 additions and 16 deletions.
Expand Up @@ -91,26 +91,33 @@ public long clean(long ttlInMs) {
long purgedMemSize = 0;
for (String key : keys) {
IStagedResource resource = resourceList.get(key);
boolean resourceIsOld = (System.currentTimeMillis() - resource.getLastUpdateTime()) > ttlInMs;
if ((resource.getState() == State.READY || resource.getState() == State.DONE)
&& (resourceIsOld || !resource.exists())) {
if (!resource.isInUse()) {
boolean file = resource.isFileResource();
long size = resource.getSize();
if (resource.delete()) {
if (file) {
purgedFileCount++;
purgedFileSize += size;
/* resource could have deleted itself between the time the keys were cloned and now */
if (resource != null) {
boolean resourceIsOld = (System.currentTimeMillis() - resource
.getLastUpdateTime()) > ttlInMs;
if ((resource.getState() == State.READY || resource.getState() == State.DONE)
&& (resourceIsOld || !resource.exists())) {
if (!resource.isInUse()) {
boolean file = resource.isFileResource();
long size = resource.getSize();
if (resource.delete()) {
if (file) {
purgedFileCount++;
purgedFileSize += size;
} else {
purgedMemCount++;
purgedMemSize += size;
}
resourceList.remove(key);
} else {
purgedMemCount++;
purgedMemSize += size;
log.warn("Failed to delete the '{}' staging resource",
resource.getPath());
}
resourceList.remove(key);
} else {
log.warn("Failed to delete the '{}' staging resource", resource.getPath());
log.info(
"The '{}' staging resource qualified for being cleaned, but was in use. It will not be cleaned right now",
resource.getPath());
}
} else {
log.info("The '{}' staging resource qualified for being cleaned, but was in use. It will not be cleaned right now", resource.getPath());
}
}
}
Expand Down

0 comments on commit 511a77f

Please sign in to comment.