protected void checkThreshold(final int count) throws IOException { if(written >= threshold) { this.reset(); this.flush(); } }
@Override public void close() throws IOException { if(close.get()) { log.warn(String.format("Skip double close of stream %s", this)); return; } try { if(written > 0L || !after.get()) { this.reset(); this.flush(); } proxy.close(); } finally { close.set(true); } }