@Override
    public void scan() {
        if (null != this.connTasks && !this.connTasks.isEmpty()) {
            Iterator<String> iter = this.connTasks.keySet().iterator();
            while (iter.hasNext()) {
                String poolKey = iter.next();
                RunStateRecordedFutureTask<ConnectionPool> task = this.connTasks.get(poolKey);
                if (task == null) {
                    logger.info("task(poolKey={}) is null, do not scan the connection pool",
                        poolKey);
                    continue;
                }

                if (!task.isDone()) {
                    logger.info("task(poolKey={}) is not done, do not scan the connection pool",
                        poolKey);
                    continue;
                }

                ConnectionPool pool = this.getConnectionPool(task);
                if (null != pool) {
                    pool.scan();
                    if (pool.isEmpty()) {
                        if ((System.currentTimeMillis() - pool.getLastAccessTimestamp()) > Constants.DEFAULT_EXPIRE_TIME) {
                            iter.remove();
                            logger.warn("Remove expired pool task of poolKey {} which is empty.",
                                poolKey);
                        }
                    }
                }
            }
        }
    }
in case of cache pollution and connection leak, to do schedule scan
src/main/java/com/alipay/remoting/DefaultConnectionManager.java