Java AsyncHttpClient和超时

Java AsyncHttpClient和超时,java,asynchttpclient,Java,Asynchttpclient,在AsyncHttpClient JDKFuture.get()中 第二个超时正在伤害我们,因为即使在超时过期后,呼叫也不会出现。它继续递归地再次调用get() 一旦ResponseTimeoutims被点击,连接会被关闭吗?我们正在尝试将其设置为低于超时。我假定您指的是我在网络中找到的方法: public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutExce

在AsyncHttpClient JDKFuture.get()中

第二个超时正在伤害我们,因为即使在超时过期后,呼叫也不会出现。它继续递归地再次调用get()


一旦ResponseTimeoutims被点击,连接会被关闭吗?我们正在尝试将其设置为低于超时。

我假定您指的是我在网络中找到的方法:

public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
    V content = null;
    try {
        if (innerFuture != null) {
            content = innerFuture.get(timeout, unit);
        }
    } catch (TimeoutException t) {
        if (!contentProcessed.get() && timeout != -1 && ((System.currentTimeMillis() - touch.get()) <= responseTimeoutInMs)) {
            return get(timeout, unit);
        }

        if (exception.get() == null) {
            timedOut.set(true);
            throw new ExecutionException(new TimeoutException(String.format("No response received after %s", responseTimeoutInMs)));
        }
    } catch (CancellationException ce) {
    }

    if (exception.get() != null) {
        throw new ExecutionException(exception.get());
    }
    return content;
}
public V get(长超时,时间单位)抛出InterruptedException、ExecutionException、TimeoutException{
V content=null;
试一试{
if(innerFuture!=null){
content=innerFuture.get(超时,单位);
}
}捕获(超时异常t){

如果(!contentProcessed.get()&&timeout!=-1&&((System.currentTimeMillis()-touch.get())不要使用JDK提供程序,它已损坏,正在AHC 2中删除。请使用Netty提供程序,并升级到现代版本。

感谢您的解释-看起来这是我们在没有作者帮助的情况下所能做到的。现有提供程序中有什么损坏(除了上面的问题)?它一直是一种从未被任何提交者使用过的玩具。它没有维护,缺少大多数功能,除了那些没有意识到他们必须提供供应商(如Netty或Grizzly)的人之外,其他人从未使用过。AHC 2将完全建在Netty之上。
  1. timeout as param
  2. responseTimeoutInMs
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
    V content = null;
    try {
        if (innerFuture != null) {
            content = innerFuture.get(timeout, unit);
        }
    } catch (TimeoutException t) {
        if (!contentProcessed.get() && timeout != -1 && ((System.currentTimeMillis() - touch.get()) <= responseTimeoutInMs)) {
            return get(timeout, unit);
        }

        if (exception.get() == null) {
            timedOut.set(true);
            throw new ExecutionException(new TimeoutException(String.format("No response received after %s", responseTimeoutInMs)));
        }
    } catch (CancellationException ce) {
    }

    if (exception.get() != null) {
        throw new ExecutionException(exception.get());
    }
    return content;
}