NIFI-3152: Ensure that we always close the IndexWriter when appropriate in SimpleIndexManager, even if an IOException is thrown when trying to commit the IndexWriter

This closes #1300.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Mark Payne 2016-12-05 14:30:57 -05:00 committed by Bryan Bende
parent 7633fe35c1
commit fc0d336f36
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 5 additions and 2 deletions

View File

@ -158,8 +158,11 @@ public class SimpleIndexManager implements IndexManager {
} else if (count.getCount() <= 1) {
// we are finished with this writer.
logger.debug("Decrementing count for Index Writer for {} to {}; Closing writer", indexingDirectory, count.getCount() - 1);
writer.commit();
count.close();
try {
writer.commit();
} finally {
count.close();
}
} else {
// decrement the count.
logger.debug("Decrementing count for Index Writer for {} to {}", indexingDirectory, count.getCount() - 1);