Skip to content

Commit

Permalink
bobo-contrib: catch block to close SegmentWriter resources if an erro…
Browse files Browse the repository at this point in the history
…r occurs in constructor
  • Loading branch information
gcooney committed Feb 10, 2012
1 parent 8e88ad5 commit 41daae6
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -41,8 +41,11 @@ public GeoSegmentWriter(Set<G> tree, Directory directory, String fileName,
this.geoRecordSerializer = geoRecordSerializer;

indexOutput = directory.createOutput(fileName);

buildBTreeFromSet(tree);
try {
buildBTreeFromSet(tree);
} finally {
close();
}
}

public GeoSegmentWriter(int treeSize, Iterator<G> inputIterator, Directory directory, String fileName,
Expand All @@ -54,7 +57,11 @@ public GeoSegmentWriter(int treeSize, Iterator<G> inputIterator, Directory direc

indexOutput = directory.createOutput(fileName);

buildBTreeFromIterator(inputIterator);
try {
buildBTreeFromIterator(inputIterator);
} finally {
close();
}
}

private void buildBTreeFromIterator(Iterator<G> geoIter) throws IOException {
Expand Down

0 comments on commit 41daae6

Please sign in to comment.