scalapb/ScalaPB

NullPointerException in __computeSerializedValue

mingyu89 opened this issue · 2 comments

Hello, I encountered the same issue as this old one #249 with a similar stacktrace.

java.lang.NullPointerException: null
	at MyMessage.__computeSerializedValue(MyMessage.scala:130) ~[classes/:?]
	at MyMessage.serializedSize(MyMessage.scala:137) ~[classes/:?]
	at com.trueaccord.scalapb.GeneratedMessage.toByteArray(GeneratedMessageCompanion.scala:93) ~[scalapb-runtime_2.12-0.5.47.jar:0.5.47]
	at com.trueaccord.scalapb.GeneratedMessage.toByteArray$(GeneratedMessageCompanion.scala:92) ~[scalapb-runtime_2.12-0.5.47.jar:0.5.47]
	at MyMessage.toByteArray(MyMessage.scala:20) ~[classes/:?]

The generated code should check both null value and isDefined.

Steps to reproduce:

  1. Create a proto message message1 with string field field1.
  2. Serialize a message1 object o1 into byte array.
  3. Update the proto message message1 and add a new string field field2
  4. Deserialize object o1 using the update message1.

It seems like you are using a very old version of scalapb. Can you try with a recent version? The specific scenario you described should not result in NPE. What serialization/deserialization methods are used? In any case, ScalaPB doesn't check for nulls if they come from the user directly passing bill to it

Closing due to inactivity.