mirror of https://github.com/apache/nifi.git
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:
parent
7633fe35c1
commit
fc0d336f36
|
@ -158,8 +158,11 @@ public class SimpleIndexManager implements IndexManager {
|
||||||
} else if (count.getCount() <= 1) {
|
} else if (count.getCount() <= 1) {
|
||||||
// we are finished with this writer.
|
// we are finished with this writer.
|
||||||
logger.debug("Decrementing count for Index Writer for {} to {}; Closing writer", indexingDirectory, count.getCount() - 1);
|
logger.debug("Decrementing count for Index Writer for {} to {}; Closing writer", indexingDirectory, count.getCount() - 1);
|
||||||
|
try {
|
||||||
writer.commit();
|
writer.commit();
|
||||||
|
} finally {
|
||||||
count.close();
|
count.close();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// decrement the count.
|
// decrement the count.
|
||||||
logger.debug("Decrementing count for Index Writer for {} to {}", indexingDirectory, count.getCount() - 1);
|
logger.debug("Decrementing count for Index Writer for {} to {}", indexingDirectory, count.getCount() - 1);
|
||||||
|
|
Loading…
Reference in New Issue