NullPointerException in __computeSerializedValue
mingyu89 opened this issue · 2 comments
mingyu89 commented
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:
- Create a proto message
message1
with string fieldfield1
. - Serialize a
message1
objecto1
into byte array. - Update the proto message
message1
and add a new string fieldfield2
- Deserialize object
o1
using the updatemessage1
.
thesamet commented
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
thesamet commented
Closing due to inactivity.