Decrement reference even if IndexShard#postRecovery barfs

This can cause a reference leak if we call `IndexShard#postRecovery`
on an already closed shard.
This commit is contained in:
Simon Willnauer 2015-05-18 14:19:05 +02:00
parent bba1528fa4
commit 470e875445
1 changed files with 7 additions and 4 deletions

View File

@ -188,12 +188,15 @@ public class RecoveryStatus extends AbstractRefCounted {
public void markAsDone() {
if (finished.compareAndSet(false, true)) {
assert tempFileNames.isEmpty() : "not all temporary files are renamed";
try {
indexShard.postRecovery("peer recovery done");
} finally {
// release the initial reference. recovery files will be cleaned as soon as ref count goes to zero, potentially now
decRef();
listener.onRecoveryDone(state());
}
}
}
/** Get a temporary name for the provided file name. */
public String getTempNameForFile(String origFile) {