Skip to content

Commit

Permalink
fix IOException when trying to read after close
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Barchfeld <markus.barchfeld@gmx.de>
  • Loading branch information
Markus Barchfeld committed Jul 20, 2016
1 parent 108b4de commit fb10234
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class OperationEmitter implements Closeable {
private int currentOpIndex;
private long startOffset;

private boolean isClosed;

/**
* Constructor.
*
Expand All @@ -71,6 +73,7 @@ public OperationEmitter(Direction direction, File file) {
determineOperationOffsets();
currentOpIndex = direction == Direction.Forward ? 0 : backwardsOffsets.size() - 1;
initReader();
isClosed = false;
}

private void determineOperationOffsets() {
Expand Down Expand Up @@ -223,6 +226,9 @@ public void run() {
}
}
}).start();
if (isClosed) {
return Optional.absent();
}

try {
return Optional.of(deserialize(pis));
Expand Down Expand Up @@ -259,6 +265,7 @@ private AbstractOperation deserialize(final PipedInputStream pis) throws IOExcep
*/
public void close() {
try {
isClosed = true;
reader.close();
} catch (final IOException ex) {
ModelUtil.logException(ex);
Expand Down

0 comments on commit fb10234

Please sign in to comment.