Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redis java.util.NoSuchElementException:池已耗尽_Java_Spring Boot_Redis_Redis Cluster - Fatal编程技术网

Redis java.util.NoSuchElementException:池已耗尽

Redis java.util.NoSuchElementException:池已耗尽,java,spring-boot,redis,redis-cluster,Java,Spring Boot,Redis,Redis Cluster,当我试图使用BoundedAsyncPool从cluster Redis获取密钥时,出现了此错误 java.util.concurrent.ExecutionException: java.util.NoSuchElementException: Pool exhausted - Unable to get key(xxx), Exception: java.util.NoSuchElementException: Pool exhausted 这是我的代码: private Integer

当我试图使用
BoundedAsyncPool
从cluster Redis获取密钥时,出现了此错误

java.util.concurrent.ExecutionException: java.util.NoSuchElementException: Pool exhausted - Unable to get key(xxx), Exception: java.util.NoSuchElementException: Pool exhausted
这是我的代码:

private Integer maxTotal = 20;
private Integer maxIdle  = 20;
private Integer minIdle = 10 ;
@覆盖
公共对象get(字符串键、类clazz){
CompletableFuture getResult=pool.acquire()。然后组合(连接->{
connection.setReadFrom(ReadFrom.REPLICA);
RedisAdvancedClusterAsyncCommands async=connection.async();
返回async.get(key).whenComplete((s,throwable)->pool.release(connection));
});
试一试{
字符串值=getResult.get();
if(StringUtils.isEmpty(值)){
返回null;
}
返回新的ObjectMapper().readValue(value,clazz);
}捕获(例外e){
LOG.error(e,String.format(“无法获取密钥(%s),异常:%s”,密钥,e.getMessage());
}
返回null;
}

您可以共享整个stracktrace吗?我似乎没有看到一个
池。closeAsync()
用于关闭打开的轮询,它们的
@Override
public Object get(String key, Class<?> clazz) {
    CompletableFuture<String> getResult = pool.acquire().thenCompose(connection -> {
        connection.setReadFrom(ReadFrom.REPLICA);
        RedisAdvancedClusterAsyncCommands<String, String> async = connection.async();
        return async.get(key).whenComplete((s, throwable) -> pool.release(connection));
    });
    try {
        String value = getResult.get();
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        return new ObjectMapper().readValue(value, clazz);
    } catch (Exception e) {
        LOG.error(e, String.format("Unable to get key(%s), Exception: %s", key, e.getMessage()));
    }
    return null;
}