Skip to content

Commit

Permalink
Invoke call.close only if call was not cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Pfattner authored and Marco Pfattner committed Feb 26, 2025
1 parent 88dee44 commit dbcaccb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stub/src/main/java/io/grpc/kotlin/ServerCalls.kt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ object ServerCalls {
else -> Status.fromThrowable(failure).withCause(failure)
}
val trailers = failure?.let { Status.trailersFromThrowable(it) } ?: GrpcMetadata()
mutex.withLock { call.close(closeStatus, trailers) }
mutex.withLock {
if (!call.isCancelled) call.close(closeStatus, trailers)
}
}

return object: ServerCall.Listener<RequestT>() {
Expand Down

0 comments on commit dbcaccb

Please sign in to comment.