code: @Override public void beforeBlock() {
      if (count > 0) {
        try {
          flush();
        } catch (IOException e) {
          logger.log(Level.SEVERE, "Flush from soy failed", e);
        }
      }
    }
docs: Soy is about to block on a future. Flush the output stream if there is anything to flush,
  so we use the time we are blocking to transfer as many bytes as possible.