Administrator
2026-11-05 300bac445dd64fe8d2bfb6b3896e15107f5b4e2c
fix(gateApi): 修复Lambda表达式变量捕获问题

- 将检查订阅超时的方法引用替换为Lambda表达式
- 定义最终变量以捕获循环中非有效最终的目标处理器
- 修复Lambda表达式中捕获非有效最终变量导致的编译问题
- 添加相关注释以说明变量捕获的修改原因
1 files modified
6 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateKlineWebSocketClient.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateKlineWebSocketClient.java
@@ -270,7 +270,7 @@
                        resubscribeRetryCount.clear();
                        if (heartbeatExecutor != null && !heartbeatExecutor.isShutdown()) {
                            subscribeTimeoutFuture = heartbeatExecutor.schedule(
                                    this::checkSubscriptionTimeout, SUBSCRIBE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
                                    () -> checkSubscriptionTimeout(), SUBSCRIBE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
                        }
                    } else {
                        log.warn("[WS] 应用正在关闭,忽略连接成功回调");
@@ -537,9 +537,11 @@
        if (heartbeatExecutor == null || heartbeatExecutor.isShutdown()) {
            return;
        }
        // target 在查找循环中被赋值,非 effectively final,须用 final 变量捕获进 lambda
        final GateChannelHandler handlerToResubscribe = target;
        heartbeatExecutor.schedule(() -> {
            if (!destroyed.get() && isConnected.get() && webSocketClient != null && webSocketClient.isOpen()) {
                target.subscribe(webSocketClient);
                handlerToResubscribe.subscribe(webSocketClient);
            }
        }, RESUBSCRIBE_DELAY_SECONDS, TimeUnit.SECONDS);
    }