This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-grpc.git


The following commit(s) were added to refs/heads/main by this push:
     new bcbacbb0 tidy up close logic (#825)
bcbacbb0 is described below

commit bcbacbb035e82f556793387d5acbda9fcbe78856
Author: PJ Fanning <[email protected]>
AuthorDate: Sat Aug 8 07:12:41 2026 +0100

    tidy up close logic (#825)
---
 .../src/main/scala/org/apache/pekko/grpc/GrpcChannel.scala    |  4 ++--
 .../pekko/grpc/internal/PekkoNettyGrpcClientGraphStage.scala  | 11 +++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/runtime/src/main/scala/org/apache/pekko/grpc/GrpcChannel.scala 
b/runtime/src/main/scala/org/apache/pekko/grpc/GrpcChannel.scala
index 9f68f1df..9de60b57 100644
--- a/runtime/src/main/scala/org/apache/pekko/grpc/GrpcChannel.scala
+++ b/runtime/src/main/scala/org/apache/pekko/grpc/GrpcChannel.scala
@@ -48,8 +48,8 @@ final class GrpcChannel private (
    * Scala API: Initiates a shutdown in which preexisting and new calls are 
cancelled.
    */
   def close(): Future[pekko.Done] = {
-    Grpc(sys).deregisterChannel(this)
-    ChannelUtils.close(internalChannel)
+    try ChannelUtils.close(internalChannel)
+    finally Grpc(sys).deregisterChannel(this)
   }
 
   /**
diff --git 
a/runtime/src/main/scala/org/apache/pekko/grpc/internal/PekkoNettyGrpcClientGraphStage.scala
 
b/runtime/src/main/scala/org/apache/pekko/grpc/internal/PekkoNettyGrpcClientGraphStage.scala
index 83bf456a..3ab1da97 100644
--- 
a/runtime/src/main/scala/org/apache/pekko/grpc/internal/PekkoNettyGrpcClientGraphStage.scala
+++ 
b/runtime/src/main/scala/org/apache/pekko/grpc/internal/PekkoNettyGrpcClientGraphStage.scala
@@ -162,12 +162,11 @@ private final class PekkoNettyGrpcClientGraphStage[I, O](
           call.request(1)
           requested += 1
         }
-      override def onDownstreamFinish(cause: Throwable): Unit =
-        if (isClosed(out)) {
-          call.cancel("Downstream cancelled", cause)
-          call = null
-          completeStage()
-        }
+      override def onDownstreamFinish(cause: Throwable): Unit = {
+        if (call != null) call.cancel("Downstream cancelled", cause)
+        call = null
+        completeStage()
+      }
 
       def onCallClosed(status: Status, trailers: Metadata): Unit = {
         if (status.isOk()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to