public Future sendRequestCore()

in src/main/java/com/aliyun/mns/common/http/DefaultServiceClient.java [72:104]


    public <T> Future<HttpResponse> sendRequestCore(
        ServiceClient.Request request, ExecutionContext context,
        HttpCallback<T> callback) throws IOException {
        assert request != null && context != null;

        HttpRequestBase httpRequest = HttpFactory.createHttpRequest(
            request, context);

        //Execute request, make the exception to the standard WebException
        Future<HttpResponse> future = null;
        try {
            future = httpClient.execute(httpRequest, callback);
        } catch (IllegalStateException e) {
            if (!((CloseableHttpAsyncClient) httpClient).isRunning()) {
                synchronized (this) {
                    //double checked
                    if (!((CloseableHttpAsyncClient) httpClient).isRunning()) {
                        //cannot restart previous client by just doing this.open() here,
                        //so, close old client and create a new one,
                        //notice: old client is abandoned to GC.
                        this.close();
                        connManager = HttpFactory.createConnectionManager(config);
                        httpClient = HttpFactory.createHttpAsyncClient(connManager, config);
                        this.open();
                    }
                }
            }

            //redo the request
            future = httpClient.execute(httpRequest, callback);
        }
        return future;
    }