Skip to content

Commit

Permalink
create defensive copy of grpc.Metadata
Browse files Browse the repository at this point in the history
fixes monix#41
  • Loading branch information
Jasper-M committed Sep 5, 2022
1 parent f17bfc3 commit a6d638c
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,19 @@ class ClientCall[Request, Response] private[client] (
case Right(_) => Task.raiseError(err)
}

private def copy(origHeaders: grpc.Metadata): grpc.Metadata = {
val newHeaders = new grpc.Metadata()
newHeaders.merge(origHeaders)
newHeaders
}

/**
* Creates a copy of the headers, because call.start can mutate them.
*/
private def start(
listener: grpc.ClientCall.Listener[Response],
headers: grpc.Metadata
): Task[Unit] = Task(call.start(listener, headers))
): Task[Unit] = Task(call.start(listener, copy(headers)))

/**
* Asks for two messages even though we expect only one so that if a
Expand Down

0 comments on commit a6d638c

Please sign in to comment.