public void finish() throws IOException {
    if (finished) {
      return;
    }
    flush();
    // Finish the stream with the terminatorValue.
    VarInt.encode(terminatorValue, os);
    if (!BUFFER_POOL.offer(buffer)) {
      // The pool is full, we can't store the buffer. We just drop the buffer.
    }
    finished = true;
  }
@Test
  public void testFinishingWhenFinishedIsNoOp() throws Exception {
    BufferedElementCountingOutputStream os = testValues(toBytes("a"));
    os.finish();
    os.finish();
    os.finish();
  }