Skip to content

Commit

Permalink
Added close() calls into catch block, in the event it fails afterLoad…
Browse files Browse the repository at this point in the history
… will be invoked
  • Loading branch information
martijnvg committed Mar 25, 2014
1 parent 2f6f550 commit b2bd806
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ public ParentChildAtomicFieldData loadDirect(AtomicReaderContext context) throws
success = true;
return data;
} finally {
for (ObjectObjectCursor<String, TypeBuilder> cursor : typeBuilders) {
cursor.value.builder.close();
}
if (success) {
estimator.afterLoad(estimatedTermsEnum, data.getMemorySizeInBytes());
} else {
estimator.afterLoad(estimatedTermsEnum, 0);
try {
for (ObjectObjectCursor<String, TypeBuilder> cursor : typeBuilders) {
cursor.value.builder.close();
}
} finally {
if (success) {
estimator.afterLoad(estimatedTermsEnum, data.getMemorySizeInBytes());
} else {
estimator.afterLoad(estimatedTermsEnum, 0);
}
}
}
}
Expand Down

0 comments on commit b2bd806

Please sign in to comment.