/** * Flushes this output stream and forces any buffered output bytes to be written out. If any data remains in the * buffer it is committed to the service. * * @throws IOException * If an I/O error occurs. */ @Override @DoesServiceRequest public void flush() throws IOException { this.checkStreamState(); this.dispatchWrite(); // Waits for all submitted tasks to complete Set<Future<Void>> requests = new HashSet<Future<Void>>(this.futureSet); for (Future<Void> request : requests) { // wait for the future to complete try { request.get(); } catch (Exception e) { throw Utility.initIOException(e); } // If that task threw an error, fail fast this.checkStreamState(); } }
private synchronized void writeInternal(final byte[] data, int offset, int length) throws IOException { while (length > 0) { this.checkStreamState();