finally: will close the connection.

@return the response on singe request
556986
public ResponseOnSingeRequest executeSshCommand() {
        ResponseOnSingeRequest sshResponse = new ResponseOnSingeRequest();

        try {
            session = startSshSessionAndObtainSession();
            channel = sessionConnectGenerateChannel(session);
            sshResponse = executeAndGenResponse((ChannelExec) channel);

        } catch (Exception e) {
            sshResponse = genErrorResponse(e);
        } finally {

            if (session != null)
                session.disconnect();
            if (channel != null)
                channel.disconnect();
        }

        return sshResponse;

    }
1154412
private String httpQuery() {

		String response = null;
		try {
			URL restUrl = new URL( this.url );
			HttpURLConnection conn = (HttpURLConnection) restUrl.openConnection();
			response = query( conn );

		} catch( Exception e ) {
			this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notification is discarded." );
			Utils.logException(this.logger, e);
		}

		return response;
	}
78213
protected Promise disconnect() {
		int s = status.get();
		if (s != STATUS_DISCONNECTED && s != STATUS_DISCONNECTING) {
			status.set(STATUS_DISCONNECTING);
			if (clientSub != null) {
				clientSub.disconnect();
			}
			if (clientPub != null) {
				clientPub.disconnect();
			}
			status.set(STATUS_DISCONNECTED);
		}
		return Promise.resolve();
	}
81551
public static void close(final HttpResponse response) {
        if (response instanceof CloseableHttpResponse) {
            val closeableHttpResponse = (CloseableHttpResponse) response;
            try {
                closeableHttpResponse.close();
            } catch (final IOException e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
1124659
private KieServerHttpRequest closeOutput() throws IOException {
        if( connection == null ) {
            throw new KieServerHttpRequestException("Please execute a HTTP method first on the request.");
        }
        if( output == null ) {
            return this;
        }
        if( ignoreCloseExceptions ) {
            try {
                output.close();
            } catch( IOException ignored ) {
                // Ignored
            }
        } else {
            output.close();
        }
        output = null;
        return this;
    }
361618
public CompletableFuture<Void> close() {
    if (client == null) {
      return CompletableFuture.completedFuture(null);
    }

    CompletableFuture<Void> future = new CompletableFuture<>();
    client.stop().whenComplete((clientResult, clientError) -> {
      if (server != null) {
        server.stop().whenComplete((serverResult, serverError) -> {
          future.complete(null);
        });
      } else {
        future.complete(null);
      }
    });
    return future;
  }
426728
public boolean limit() {

        //get connection
        Object connection = getConnection();

        Object result = limitRequest(connection);

        if (FAIL_CODE != (Long) result) {
            return true;
        } else {
            return false;
        }
    }
1269465
@SuppressWarnings("unchecked")
    public CompletableFuture<Void> close() {

        this.closed = true;

        List<CompletableFuture<Void>> futures = new ArrayList<>();

        forEach((connectionKey, closeable) -> {

            futures.add(closeable.closeAsync());
            connections.remove(connectionKey);
        });

        return Futures.allOf(futures);
    }
346056
public boolean close() {
    if (open.compareAndSet(true, false)) {
      futures.forEach(future -> future.completeExceptionally(new IllegalStateException("Closed session")));
      return true;
    }
    return false;
  }
684520
@Override
    public void shutdown() {
        synchronized (connections) {
            parent.channelCloses(this);
            for (final MessageInbound connection : connections) {
                try {
                    connection.getWsOutbound().close(0, null);
                } catch (final IOException e) {
                    LOG.error("Connection [" + connection.toString() + "] can't be closed.", e);
                } finally {
                    final ExecutorService executorService = connectionThreads.get(connection);
                    if (executorService != null) {
                        executorService.shutdown();
                    }
                    connectionThreads.remove(connection);
                }
            }
            connections.clear();
        }
        callback = null;
    }
1155262
HTTPResponse getHTTPResponse() {
        lock.lock();
        try {
            while (response == null) {
                try {
                    ready.await();
                } catch (InterruptedException intx) {
                    LOG.log(Level.FINEST, "Interrupted", intx);
                }
            }
            return response;
        } finally {
            lock.unlock();
        }
    }
630837
public static void end()
    {
        ServiceContext context = (ServiceContext) _localContext.get();

        if (context != null && --context._count == 0) {
            context._request = null;
            context._response = null;

            context._headers.clear();

            _localContext.set(null);
        }
    }
698952
@Override
  protected void close() {
    this.stop = true;

    // Close the socket to force blocking operations to return.
    if (this.socket != null && !this.socket.isClosed()) {
      this.socket.close();
    }
  }
1099250
@Override
    public void close() {
        if (client != null) {
            try {
                client.close();
            } catch (final IOException e) {
                LOGGER.error("Unable to close HTTP client", e);
            }
        }
    }
82110
public void close() {
        try {
            // Request BMP to create a new HAR for this Proxy
            HttpDelete shutdownProxyDELETE = new HttpDelete(requestURIBuilder()
                    .setPath(proxyURIPath())
                    .build());

            // Execute request
            CloseableHttpResponse response = HTTPclient.execute(shutdownProxyDELETE);

            // Check request was successful
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode != 200) {
                throw new BMPCUnableToCloseProxyException(String.format(
                        "Invalid HTTP Response when attempting to close " +
                                "Proxy '%d'. Status code: %d",
                        proxyPort, statusCode));
            }
            // Close HTTP Response
            response.close();

            // Close HTTP Client
            HTTPclient.close();
        } catch (Exception e) {
            throw new BMPCUnableToCloseProxyException(e);
        }
    }
1193421
protected void destroy()
    {
        try{close();}
        catch (IOException e){LogSupport.ignore(log,e);}
        catch (Exception e){log.warn(LogSupport.EXCEPTION,e);}
        
        // Destroy request and response
        if (_request!=null)
            _request.destroy();
        if (_response!=null)
            _response.destroy();
        if (_inputStream!=null)
            _inputStream.destroy();
        if (_outputStream!=null)
            _outputStream.destroy();
        _inputStream=null;
        _outputStream=null;
        _request=null;
        _response=null;
        _handlingThread=null;
        
        if (_statsOn)
        {
            _tmpTime=System.currentTimeMillis();
            if (_reqTime>0)
                _httpServer.statsEndRequest(_tmpTime-_reqTime,false);
            _httpServer.statsCloseConnection(_tmpTime-_openTime,_requests);
        }
    }
396806
@Override
    public void abort() {
        if (this.aborted) {
            return;
        }
        this.aborted = true;
        HttpConnection conn = this.responseConnection; 
        if (conn != null) {
            conn.close();
        }
    }