Skip to content

Commit 3645376

Browse files
mopfattnMarco Pfattner
authored and
Marco Pfattner
committed
Invoke call.close only if call was not cancelled
1 parent 88dee44 commit 3645376

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stub/src/main/java/io/grpc/kotlin/ServerCalls.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ object ServerCalls {
265265
else -> Status.fromThrowable(failure).withCause(failure)
266266
}
267267
val trailers = failure?.let { Status.trailersFromThrowable(it) } ?: GrpcMetadata()
268-
mutex.withLock { call.close(closeStatus, trailers) }
268+
mutex.withLock {
269+
if (!call.isCancelled) call.close(closeStatus, trailers)
270+
}
269271
}
270272

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

0 commit comments

Comments
 (0)