0

以下は、PoolingNHttpClientConnectionManager から NHttpClientConnection を要求するコードです。connFuture.get() の呼び出しが返されません。誰でも理由を知っていますか?HttpAsyncClient ライブラリ httpasyncclient-4.0.1.jar を使用しています

static NHttpClientConnection httpConn = null;
public static void testOne() throws Exception {
    ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor();
    PoolingNHttpClientConnectionManager connManager = new PoolingNHttpClientConnectionManager(ioReactor);
    connManager.setMaxTotal(100);

    long connectTimeout=1;
    long leaseTimeout=4;
    TimeUnit timeUnit = TimeUnit.SECONDS;
    Object state = null;

    HttpRoute route = new HttpRoute(new HttpHost("www.google.com", 80));
    Future<NHttpClientConnection> connFuture = connManager.requestConnection(route, state, connectTimeout, leaseTimeout, timeUnit, 
            new FutureCallback<NHttpClientConnection>() {
        public void completed(final NHttpClientConnection c) {
            System.out.println("completed");
            httpConn = c;
        }
        public void failed(final Exception ex) {
            System.out.println("failed");
        }
        public void cancelled() {
            System.out.println("cancelled");
        }
    } );
    System.out.println("Step3");
    connFuture.get(); // Failed to return
    System.out.println("Done");
}
4

1 に答える 1