@Override public void flush() throws IOException { synchronized (statusLock) { // Make sure HTTP status and header is specified. statusLock.notifyAll(); } byte[] b = Arrays.copyOf(buffer, offset); target.write(b); offset = 0; }