code: public void close() throws IOException, InterruptedException {
      LOG.debug("closing connection");
      stream.close();
      uplink.closeConnection();
      uplink.interrupt();
      uplink.join();
    }
docs: Close the connection and shutdown the handler thread.
  @throws IOException
  @throws InterruptedException