From 091359b450a7d0fb6bb04e2238c9171728cd2720 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 28 Mar 2017 16:11:25 -0400 Subject: [PATCH] NIFI-3630 This closes #1632. Use a BufferedOutputStream when checkpointing FlowFile Repository Signed-off-by: joewitt --- .../java/org/wali/MinimalLockingWriteAheadLog.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java b/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java index 1a9e219d66..5334acb3c3 100644 --- a/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java +++ b/nifi-commons/nifi-write-ahead-log/src/main/java/org/wali/MinimalLockingWriteAheadLog.java @@ -569,7 +569,7 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor // perform checkpoint, writing to .partial file fileOut = new FileOutputStream(partialPath.toFile()); - dataOut = new DataOutputStream(fileOut); + dataOut = new DataOutputStream(new BufferedOutputStream(fileOut)); dataOut.writeUTF(MinimalLockingWriteAheadLog.class.getName()); dataOut.writeInt(getVersion()); dataOut.writeUTF(serde.getClass().getName()); @@ -590,9 +590,12 @@ public final class MinimalLockingWriteAheadLog implements WriteAheadRepositor } finally { if (dataOut != null) { try { - dataOut.flush(); - fileOut.getFD().sync(); - dataOut.close(); + try { + dataOut.flush(); + fileOut.getFD().sync(); + } finally { + dataOut.close(); + } } catch (final IOException e) { logger.warn("Failed to close Data Stream due to {}", e.toString(), e); }