修改回调机制

This commit is contained in:
孙小云 2026-02-11 10:24:15 +08:00
parent 8f85fc7a1e
commit 1507e758cd
1 changed files with 9 additions and 0 deletions

View File

@ -204,6 +204,15 @@ public class TransactionExecutor {
}
}, commandExecutor).thenCompose(remoteCallSuccess -> {
if (!remoteCallSuccess) {
// 命令发送失败取消已注册的回调避免资源泄漏
if (finalMethodFuture != null) {
log.warn("命令发送失败,取消方法回调");
finalMethodFuture.cancel(true);
}
if (finalStateFuture != null) {
log.warn("命令发送失败,取消状态回调");
finalStateFuture.cancel(true);
}
InstructionResult result = InstructionResult.failure("远程调用失败");
instruction.onComplete(context, result);
return CompletableFuture.completedFuture(result);