Matt Wagner
02/27/2024, 5:30 PMMatt Wagner
02/27/2024, 5:33 PMcase class PBSerializer[T <: GeneratedMessage](companion: GeneratedMessageCompanion[T])
extends Serializer[PBMessage[T]] {
setAcceptsNull(false)
setImmutable(true)
def read(kryo: Kryo, input: Input, typ: Class[PBMessage[T]]): PBMessage[T] = {
new PBMessage(companion.parseFrom(input))
}
def write(kryo: Kryo, output: Output, obj: PBMessage[T]): Unit = {
output.write(obj.message.toByteArray)
}
}
In this case, companion is the companion object ScalaPB provides to handle [de]serialization. I get com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero). which smells like it's either getting unexpectedly empty data, or getting empty data after the end of the expected data.Matt Wagner
02/27/2024, 5:34 PMinput.readAllBytes() to read so I could log some info out, that call runs forever.Matt Wagner
02/27/2024, 7:06 PMwrite and then only reading that many more bytes in read - apparently the input stream here doesn't have a fixed length