code: 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;
      }
    }
docs: close the stream
  
  @param msg close message
  @param length length