Skip to content

Commit

Permalink
Corrected NPE in FileDataWriter.close
Browse files Browse the repository at this point in the history
  • Loading branch information
rhauch committed Dec 22, 2016
1 parent 522fd34 commit 2ab4f40
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions strongback/src/org/strongback/FileDataWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public FileDataWriter(Iterable<DataRecorderChannel> channels, Supplier<String> f
fileSize = numWrites * recordLength + 1024; // add extra room for header and miscellaneous

AtomicInteger count = new AtomicInteger();
channels.forEach(ch->count.incrementAndGet());
channels.forEach(ch -> count.incrementAndGet());
channelCount = count.get() + 1; // adding the time sequence

openIfNeeded();
Expand Down Expand Up @@ -87,7 +87,7 @@ protected void openIfNeeded() {
assert name != null;
writer.write(name);
});
} else if ( writer.remaining() < recordLength) {
} else if (writer.remaining() < recordLength) {
System.err.println("Insuffient space to write next all of next record, closing file");
close();
openIfNeeded();
Expand All @@ -103,11 +103,13 @@ public void write(long time) {

@Override
public void close() {
try {
writer.close();
} finally {
writer = null;
suppliers.clear();
if (writer != null) {
try {
writer.close();
} finally {
writer = null;
suppliers.clear();
}
}
}

Expand Down

0 comments on commit 2ab4f40

Please sign in to comment.