code: private void flush(boolean endOfRecord) throws IOException {
          if (buffer == null) {
              if (!endOfRecord || eorSent) {
                  return;
              }
              ensureBufferAvailable();
          }
          if (buffer.position() == 0 && (!endOfRecord || eorSent)) {
              // Nothing to flush
              buffer.unlockBuffer();
          } else {
              if (sendInputEvents) {
                  eventPipeline.fire(Input.fromSink(buffer, endOfRecord),
                      channel);
              } else {
                  eventPipeline.fire(Output.fromSink(buffer, endOfRecord),
                      channel);
              }
              eorSent = endOfRecord;
          }
          buffer = null;
      }
docs: Creates and fires an {@link Output} event with the buffer being filled.
  The end of record flag of the event is set according to the parameter.
  Frees any allocated buffer.