From dc223347c714d8c8cde6889510d90c051851a64e Mon Sep 17 00:00:00 2001 From: caoyanan666 <55247691+caoyanan666@users.noreply.github.com> Date: Sun, 7 Apr 2024 14:56:35 +0800 Subject: [PATCH] fix(3.2): triple AbstractServerCallListener NPE (#14009) * fix NPE * Optimize the handling of exceptions in response --------- Co-authored-by: caoyanan --- .../rpc/protocol/tri/call/AbstractServerCallListener.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java index 7fa838d8d75b..879cf44e1010 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java @@ -62,14 +62,18 @@ public void invoke() { final long stInMillis = System.currentTimeMillis(); try { final Result response = invoker.invoke(invocation); + if (response.hasException()) { + doOnResponseHasException(response.getException()); + return; + } response.whenCompleteWithContext((r, t) -> { responseObserver.setResponseAttachments(response.getObjectAttachments()); if (t != null) { responseObserver.onError(t); return; } - if (response.hasException()) { - doOnResponseHasException(response.getException()); + if (r.hasException()) { + doOnResponseHasException(r.getException()); return; } final long cost = System.currentTimeMillis() - stInMillis;