BufferedElementCountingOutputStream extends OutputStream { @Override public void flush() throws IOException { if (finished) { return; } outputBuffer(); os.flush(); } BufferedElementCountingOutputStream(OutputStream os);  BufferedElementCountingOutputStream(OutputStream os, long terminatorValue);   BufferedElementCountingOutputStream(OutputStream os, int bufferSize, long terminatorValue); void finish(); void markElementStart(); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close(); static final int DEFAULT_BUFFER_SIZE; }
@Test public void testFlushingWhenFinishedIsNoOp() throws Exception { BufferedElementCountingOutputStream os = testValues(toBytes("a")); os.flush(); os.flush(); os.flush(); }