A stream obtained via this call must be closed before using other APIs of
this class or else the invocation will block.
496287
@Override
  public FSDataOutputStream create(Path file, FsPermission permission,
      boolean overwrite, int bufferSize, short replication, long blockSize,
      Progressable progress) throws IOException {
    final FTPClient client = connect();
    Path workDir = new Path(client.printWorkingDirectory());
    Path absolute = makeAbsolute(workDir, file);
    if (exists(client, file)) {
      if (overwrite) {
        delete(client, file);
      } else {
        disconnect(client);
        throw new IOException("File already exists: " + file);
      }
    }
    Path parent = absolute.getParent();
    if (parent == null || !mkdirs(client, parent, FsPermission.getDefault())) {
      parent = (parent == null) ? new Path("/") : parent;
      disconnect(client);
      throw new IOException("create(): Mkdirs failed to create: " + parent);
    }
    client.allocate(bufferSize);
    // Change to parent directory on the server. Only then can we write to the
    // file on the server by opening up an OutputStream. As a side effect the
    // working directory on the server is changed to the parent directory of the
    // file. The FTP client connection is closed when close() is called on the
    // FSDataOutputStream.
    client.changeWorkingDirectory(parent.toUri().getPath());
    FSDataOutputStream fos = new FSDataOutputStream(client.storeFileStream(file
        .getName()), statistics) {
      @Override
      public void close() throws IOException {
        super.close();
        if (!client.isConnected()) {
          throw new FTPException("Client not connected");
        }
        boolean cmdCompleted = client.completePendingCommand();
        disconnect(client);
        if (!cmdCompleted) {
          throw new FTPException("Could not complete transfer, Reply Code - "
              + client.getReplyCode());
        }
      }
    };
    if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
      // The ftpClient is an inconsistent state. Must close the stream
      // which in turn will logout and disconnect from FTP server
      fos.close();
      throw new IOException("Unable to create file: " + file + ", Aborting");
    }
    return fos;
  }
894069
public void close() {
    if (lock != null) {
      lock.lock();
    }
    this.connected = false;
    try {
      /* If a streaming result set is open, close it.*/
      skip();
    } catch (Exception e) {
      /* eat exception */
    }

    SendClosePacket.send(writer);
    closeSocket(reader, writer, socket);
    cleanMemory();
    if (lock != null) {
      lock.unlock();
    }
  }
78331
public void close() throws IOException {
        if (closeRequested)
            return;
        guard.close();
        closeRequested = true;

        synchronized (this) {
            // Close streams, release their inflaters
            synchronized (streams) {
                if (false == streams.isEmpty()) {
                    Map<InputStream, Inflater> copy = new HashMap<>(streams);
                    streams.clear();
                    for (Map.Entry<InputStream, Inflater> e : copy.entrySet()) {
                        e.getKey().close();
                        Inflater inf = e.getValue();
                        if (inf != null) {
                            inf.end();
                        }
                    }
                }
            }

            // Release cached inflaters
            Inflater inf;
            synchronized (inflaterCache) {
                while (null != (inf = inflaterCache.poll())) {
                    inf.end();
                }
            }

            if (jzfile != 0) {
                // Close the zip file
                long zf = this.jzfile;
                jzfile = 0;

                close(zf);
            }

            // Android-changed, explicit delete for OPEN_DELETE ZipFile.
            if (fileToRemoveOnClose != null) {
                fileToRemoveOnClose.delete();
            }
        }
    }
307321
private void closeStreams(final Process process) throws IOException {
    IOException caught = null;

    try {
      process.getOutputStream().close();
    }
    catch (IOException e) {
      if (e.getMessage().equals("Stream closed")) {
        /**
         * OutputStream's contract for the close() method: If the stream is already closed then invoking this method has no effect.
         *
         * When a UNIXProcess exits ProcessPipeOutputStream automatically closes its target FileOutputStream and replaces it with NullOutputStream.
         * However the ProcessPipeOutputStream doesn't close itself at that moment.
         * As ProcessPipeOutputStream extends BufferedOutputStream extends FilterOutputStream closing it flushes the buffer first.
         * In Java 7 closing FilterOutputStream ignores any exception thrown by the target OutputStream. Since Java 8 these exceptions are now thrown.
         *
         * So since Java 8 after UNIXProcess detects the exit and there's something in the output buffer closing this stream throws IOException
         * with message "Stream closed" from NullOutputStream.
         */
        log.trace("Failed to close process output stream:", e);
      }
      else {
        log.error("Failed to close process output stream:", e);
        caught = add(caught, e);
      }
    }

    try {
      process.getInputStream().close();
    }
    catch (IOException e) {
      log.error("Failed to close process input stream:", e);
      caught = add(caught, e);
    }

    try {
      process.getErrorStream().close();
    }
    catch (IOException e) {
      log.error("Failed to close process error stream:", e);
      caught = add(caught, e);
    }

    if (caught != null) {
      throw caught;
    }
  }
1162591
function close() {
		if ( error ) {
			debug( 'Stream was destroyed due to an error. Error: %s.', JSON.stringify( error ) );
			self.emit( 'error', error );
		}
		debug( 'Closing the stream...' );
		self.emit( 'close' );
	}
1066068
protected void handleStream() {
        inboundStreamHandler.handle(new ISignalWriteStream() {
            boolean streamFinished = false;

            @Override
            public void write(IApimanBuffer buffer) {
                if (streamFinished) {
                    throw new IllegalStateException("Attempted write after #end() was called."); //$NON-NLS-1$
                }
                requestChain.write(buffer);
            }

            @Override
            public void end() {
                requestChain.end();
                streamFinished = true;
            }

            /**
             * @see io.apiman.gateway.engine.io.IAbortable#abort()
             */
            @Override
            public void abort(Throwable t) {
                // If this is called, it means that something went wrong on the inbound
                // side of things - so we need to make sure we abort and cleanup the
                // api connector resources.  We'll also call handle() on the result
                // handler so that the caller knows something went wrong.
                streamFinished = true;
                apiConnection.abort(t);
                resultHandler.handle(AsyncResultImpl.<IEngineResult>create(new RequestAbortedException(t)));
            }


            @Override
            public boolean isFinished() {
                return streamFinished;
            }

            @Override
            public void drainHandler(IAsyncHandler<Void> drainHandler) {
                apiConnection.drainHandler(drainHandler);
            }

            @Override
            public boolean isFull() {
                return apiConnection.isFull();
            }
        });
    }
1091357
public void close() throws IOException {   
    if (closed) {
      checkWriteThread();
      return;
    }
    try {
      buffer.close(); 
      // writeThread should exit after this
      // and close underlying stream
      try {
        writeThread.join();
      } catch (InterruptedException e) {
        throw new IOException(e);
      }
    } finally {
      checkWriteThread();
    }
  }
793322
public void close() {
    if (this.isDisabled || this.closed) {
      // parent stream needs to check for success explicitly
      return;
    }
    closed = true;
    try {
      // send close request
      tasks.add(sendExecutor.submit(new SendWorker(
          new ByteArrayOutputStream(0), segmentId++, true)));

      // wait for all tasks to complete
      for (Future<Void> task : tasks) {
        task.get();
      }
    } catch (InterruptedException e) {
      setErrorStatus("Interrupted exception", e);
    } catch (ExecutionException e) {
      setErrorStatus("Execution exception", e);
    } finally {
      // close the executor
      sendExecutor.shutdownNow();
    }
  }
1261043
public void close() throws IOException {
        if (this.debug) {
            System.err.println("TarBuffer.closeBuffer().");
        }

        if (this.outStream != null) {
            this.flushBlock();

            if (this.outStream != System.out && this.outStream != System.err) {
                this.outStream.close();
                this.outStream = null;
            }
        } else if (this.inStream != null) {
            if (this.inStream != System.in) {
                this.inStream.close();
                this.inStream = null;
            }
        }
    }
595109
function (stream, close) {
                this._stream = stream;
                if (typeof close === "function") {
                    this._close = close;
                }
                stream.on("error", this._onError.bind(this));
            }
1355067
function onResultStreamClose(err, continueCallback)
  {
    // if the error is retryable and
    // the result stream hasn't been closed too many times
    if (isResultStreamErrorRetryable(err) &&
        (numResultStreamInterrupts <
        context.connectionConfig.getResultStreamInterrupts()))
    {
      numResultStreamInterrupts++;

      // fetch the statement result again
      context.refresh(function()
      {
        if (context.resultError)
        {
          close(context.resultError);
        }
        else
        {
          continueCallback();
        }
      });
    }
    else
    {
      close(err);
    }
  }
412976
public void close() throws java.io.IOException{
        synchronized(this){
            if(_outHelper.isOutputStream_closed()){
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "output stream close previously completed ...return ");
                }
                return;
            }
            else{
                _outHelper.closeWork();
            }
        }
    }
263110
public void close()
  {
    StreamSource ss = _indirectSource;
    _indirectSource = null;
    
    if (ss != null) {
      ss.freeUseCount();
    }
    else {
      freeUseCount();
    }
  }
775380
@Override
    public void close() {
        if (this.inputStream != null) {
            try {
                this.inputStream.close();
            } catch (final IOException e) {
                // Ignore
            }
            this.inputStream = null;
        }
        this.byteBuffer = null;
        this.buf = null;
    }
355447
@Override
    public void close() {
        if (!this.closed) {
            this.closed = true;

            // If we have already returned a result but it hasn't been consumed yet, cancel it.
            CompletableFuture<ReadResultEntryContents> lastReturnedFuture = this.lastEntryFuture;
            if (lastReturnedFuture != null && !lastReturnedFuture.isDone()) {
                lastReturnedFuture.cancel(true);
                this.lastEntryFuture = null;
            }

            log.trace("{}.ReadResult[{}]: Closed.", this.traceObjectId, this.streamSegmentStartOffset);
        }
    }
570991
@Override
  public void close() throws IOException
  {
      if(this.in != null && this.inStream != null){
          if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
              logger.logp(Level.FINE, CLASS_NAME,"close", "close called->"+this);
          }
          this.in.close();
      }
      else{
          super.close();
      }
  }
286978
public void close()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "close");

    Enumeration streams = null;
    synchronized (this)
    {
      synchronized (streamTable)
      {
        closed = true;
        closeBrowserSessionsInternal();
        streams = streamTable.elements();
      }
    }
    // since already set closed to true, no more AOStreams will be created and added to the streamTable,
    // even if there is an
    // asynchronous stream creation in progress (the itemStream will be created, but no AOStream will
    // be added to the streamTable).
    while (streams.hasMoreElements())
    {
      StreamInfo sinfo = (StreamInfo) streams.nextElement();
      if (sinfo.stream != null)
      {
        sinfo.stream.close();
      }
    }

    synchronized (streamTable)
    {
      streamTable.clear();
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "close");
  }