close the stream

@param msg close message
@param length length
185967
private void closeStream(String msg, long length) {
    if (wrappedStream != null) {
      long remaining = remainingInCurrentRequest();
      boolean shouldAbort = remaining > readahead;
      if (!shouldAbort) {
        try {
          wrappedStream.close();
        } catch (IOException e) {
          LOG.debug("When closing {} stream for {}", uri, msg, e);
          shouldAbort = true;
        }
      }
      if (shouldAbort) {
        wrappedStream.abort();
      }
      LOG.trace("Close stream {} {}: {}; streamPos={}, nextReadPos={},"
          + " request range {}-{} length={}", uri, (shouldAbort ? "aborted" : "closed"), msg,
          pos, nextReadPos, contentRangeStart, contentRangeFinish, length);
      wrappedStream = null;
    }
  }
138168
private synchronized void reopen(String msg, long targetPos, long length) throws IOException {
    if (wrappedStream != null) {
      closeStream("reopen(" + msg + ")", contentRangeFinish);
    }
    contentRangeStart = targetPos;
    contentRangeFinish = targetPos + Math.max(readahead, length) + threasholdRead;
    if (negativeSeek < 0) {
      contentRangeFinish = targetPos + Math.abs(negativeSeek);
      negativeSeek = 0;
    }
    try {
      LOG.trace("reopen({}) for {} range[{}-{}], length={},"
          + " streamPosition={}, nextReadPosition={}", uri, msg,
          contentRangeStart, contentRangeFinish, length, pos, nextReadPos);

      wrappedStream = SwiftAPIDirect.getObject(new Path(uri),
          mJossAccount, contentRangeStart, contentRangeFinish, scm);
      if (wrappedStream == null) {
        throw new IOException("Null IO stream from reopen of (" + msg + ") " + uri);
      }
    } catch (ClientException e) {
      LOG.error(e.getMessage());
      throw new IOException("Reopen at position " + targetPos + uri);
    }
    pos = targetPos;
  }
1275067
def close (self):
        """"""
        if self._stream:
            values = ( self._total.nbytes,
                       self._total.npackets,
                       int( math.ceil(self._total.nseconds) ),
                       self._filename )

            if self._dryrun:
                msg = 'Would write %d bytes, %d packets, %d seconds to %s.'
            else:
                msg = 'Wrote %d bytes, %d packets, %d seconds to %s.'
                self._stream.close()

            log.info(msg % values)

            self._filename  = None
            self._startTime = None
            self._stream    = None
            self._total     = PCapFileStats(0, 0, 0)
153244
@Override
    public void close() throws IOException {
        InputStream is = getObjectContent();
        if (is != null)
            is.close();
    }
823018
public static void close (InputStream in)
    {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ioe) {
                log.warning("Error closing input stream", "stream", in, "cause", ioe);
            }
        }
    }
406209
@Override
    public void close() throws IOException {
        if (out != null) {
            IOException ex = null;
            try {
                if (position > 0) {
                    if (breakLines && lineLength >= Base64.MAX_LINE_LENGTH) {
                        if (crlf) {
                            out.write(Base64.CR);
                        }
                        out.write(Base64.LF);
                    }

                    int len = Base64.encode3to4(buffer, 0, position, b4, 0, noPadding, alphabet);
                    out.write(b4, 0, len);
                }
                out.flush();
            } catch (IOException e) {
                ex = e;
            }

            try {
                // 2. Actually close the stream
                // Base class both flushes and closes.
                if (close) {
                    out.close();
                }
            } catch (IOException e) {
                if (ex != null) {
                    ex.addSuppressed(e);
                } else {
                    throw e;
                }
            } finally {
                out = null;
            }

            if (ex != null) {
                throw ex;
            }
        }
    }
585910
public static void sendClose(final CloseMessage closeMessage, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) {
        sendClose(closeMessage, wsChannel, callback, null);
    }
1342844
@Override
    public void close() throws IOException
    {
        InputStream in = mIn;

        if (in != null) {
            mIn = null;
            freeBuffers();
            in.close();
        }
    }
1327196
def close(self, code=1000, message=''):
        
        try:
            message = self._encode_bytes(message)
            self.send_frame(
                struct.pack('!H%ds' % len(message), code, message),
                opcode=self.OPCODE_CLOSE)
        except WebSocketError:
            # Failed to write the closing frame but it's ok because we're
            # closing the socket anyway.
            logger.debug("Failed to write closing frame -> closing socket")
        finally:
            logger.debug("Closed WebSocket")
            self._closed = True
            self.stream = None
640959
public static boolean close(final InputStream[] streams) {
      boolean success = true;

      for (InputStream stream : streams) {
         boolean rv = close(stream);
         if (!rv) success = false;
      }

      return success;
   }
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' );
	}
735978
public void closeJsonStream() throws IOException {
		if (generator == null) {
			return;
		}

		while (!stack.isEmpty()) {
			writeEndComponent();
		}

		if (wrapInArray) {
			generator.writeEndArray();
		}

		if (closeGenerator) {
			generator.close();
		}
	}
74029
public void close() throws IOException {
        if (open) {
            if (residual.length() > 0) {
                throw new IOException("Base64 error - data is not properly"
                        + "padded to 4-character groups.");
            }
            stream.close();
            open = false;
        }
    }
583608
async def close(self, code: int=1000, message: bytes=b'') -> None:
        """"""
        if isinstance(message, str):
            message = message.encode('utf-8')
        try:
            await self._send_frame(
                PACK_CLOSE_CODE(code) + message, opcode=WSMsgType.CLOSE)
        finally:
            self._closing = True
998917
public void close() {
        //log.debug("Stream close: {}", publishedName);
        if (closed.compareAndSet(false, true)) {
            if (livePipe != null) {
                livePipe.unsubscribe((IProvider) this);
            }
            // if we have a recording listener, inform that this stream is done
            if (recordingListener != null) {
                sendRecordStopNotify();
                notifyRecordingStop();
                // inform the listener to finish and close
                recordingListener.get().stop();
            }
            sendPublishStopNotify();
            // TODO: can we send the client something to make sure he stops sending data?
            if (connMsgOut != null) {
                connMsgOut.unsubscribe(this);
            }
            notifyBroadcastClose();
            // clear the listener after all the notifications have been sent
            if (recordingListener != null) {
                recordingListener.clear();
            }
            // clear listeners
            if (!listeners.isEmpty()) {
                listeners.clear();
            }
            // deregister with jmx
            unregisterJMX();
            setState(StreamState.CLOSED);
        }
    }
145024
private void writeLengthToStream(int length, OutputStream out) throws IOException {
    sharedByteBuffer.clear();
    sharedByteBuffer.order(ByteOrder.BIG_ENDIAN).putInt(length);
    sharedByteBuffer.flip();
    out.write(sharedByteBuffer.array(), 0, Ints.BYTES);
    sharedByteBuffer.order(byteOrder);
  }
1347051
public static <S extends Closeable> void closeOnComplete(S stream, StreamTask<S> task) {
        closeOnComplete(stream, task, DEFAULT_ERROR_HANDLER);
    }