-
Notifications
You must be signed in to change notification settings - Fork 542
Closed
Labels
Description
It seems java codegen tool not fully aware of optional fields. We are getting NPE during decode our new traceContext2 field. This field is available since version 3 of our schema and marked as optional.
<field xmlns="" name="traceContext2" id="4" type="TraceContext" description="Distributed Trace Context" presence="optional" sinceVersion="3"/>
If we will try to send message with version 2 and call toString we will obtain an NPE
Reported exception:
java.lang.NullPointerException
at com.mlp.ctp.generic.MessageAckDecoder.appendTo(MessageAckDecoder.java:352)
at com.mlp.ctp.generic.MessageAckDecoder.toString(MessageAckDecoder.java:308)
Generated code:
toString:
builder.append('|');
builder.append("traceContext2=");
this.traceContext2().appendTo(builder);
traceContext2() method:
public TraceContextDecoder traceContext2() {
if (this.parentMessage.actingVersion < 3) {
return null;
} else {
this.traceContext2.wrap(this.buffer, this.offset + 16);
return this.traceContext2;
}
}