The variant of SafeMetadata.make that takes pairs creates the Metadata object eagerly outside of the effect. That means that the same Metadata object will be used everytime we create SafeMetadata. That leads to catastrophic behavior as that object is not supposed to be shared and reused (java.lang.NullPointerException: Cannot invoke "io.grpc.Metadata$LazyValue.toBytes()" because "value" is null or Uncaught exception in the SynchronizationContext. Panic! in Netty).
The variant of
SafeMetadata.make
that takes pairs creates theMetadata
object eagerly outside of the effect. That means that the sameMetadata
object will be used everytime we createSafeMetadata
. That leads to catastrophic behavior as that object is not supposed to be shared and reused (java.lang.NullPointerException: Cannot invoke "io.grpc.Metadata$LazyValue.toBytes()" because "value" is null
orUncaught exception in the SynchronizationContext. Panic!
in Netty).This PR makes the creation of
Metadata
lazy.