HBASE-19502 Make sure we have closed all StoreFileScanner if we fail to open any StoreFileScanners

This commit is contained in:
Chia-Ping Tsai 2017-12-13 21:30:08 +08:00
parent 536187446d
commit 7f586995a8
1 changed files with 19 additions and 9 deletions

View File

@ -137,6 +137,8 @@ public class StoreFileScanner implements KeyValueScanner {
file.initReader();
sortedFiles.add(file);
}
boolean succ = false;
try {
for (int i = 0, n = files.size(); i < n; i++) {
HStoreFile sf = sortedFiles.remove();
StoreFileScanner scanner;
@ -148,6 +150,14 @@ public class StoreFileScanner implements KeyValueScanner {
}
scanners.add(scanner);
}
succ = true;
} finally {
if (!succ) {
for (StoreFileScanner scanner : scanners) {
scanner.close();
}
}
}
return scanners;
}