HBASE-19502 Make sure we have closed all StoreFileScanner if we fail to open any StoreFileScanners
This commit is contained in:
parent
a1ec048d2d
commit
54ca1db6bd
|
@ -132,6 +132,8 @@ public class StoreFileScanner implements KeyValueScanner {
|
|||
List<StoreFileScanner> scanners = new ArrayList<StoreFileScanner>(files.size());
|
||||
List<StoreFile> sorted_files = new ArrayList<>(files);
|
||||
Collections.sort(sorted_files, StoreFile.Comparators.SEQ_ID);
|
||||
boolean succ = false;
|
||||
try {
|
||||
for (int i = 0; i < sorted_files.size(); i++) {
|
||||
StoreFile.Reader r = sorted_files.get(i).createReader(canUseDrop);
|
||||
r.setReplicaStoreFile(isPrimaryReplica);
|
||||
|
@ -139,6 +141,14 @@ public class StoreFileScanner implements KeyValueScanner {
|
|||
i, matcher != null ? !matcher.hasNullColumnInQuery() : false);
|
||||
scanners.add(scanner);
|
||||
}
|
||||
succ = true;
|
||||
} finally {
|
||||
if (!succ) {
|
||||
for (StoreFileScanner scanner : scanners) {
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return scanners;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue