-
Bug
-
Resolution: Done
-
Major
-
1.33.0.Final
-
None
-
False
-
None
-
False
-
---
-
---
-
2023 Week 09-11 (from Feb 27)
-
Important
It seems that ProtoGenerator in conjunction with MarshallerGenerator fails on marshaller code generation when trying to place read and write methods for array and collection fields of serializable classes on a given POJO.
Below example shows the issue:
public class Person { private String id; private String name; ... private Money[] earnings; // Money implements Serializable private List<Money> expenses; // Money implements Serializable }
Above POJO input generates the following message marshaller java class that does not compile properly due to some cast operations:
public class PersonMessageMarshaller implements MessageMarshaller<org.kie.kogito.codegen.data.Person> { public java.lang.Class<org.kie.kogito.codegen.data.Person> getJavaClass() { return org.kie.kogito.codegen.data.Person.class; } public String getTypeName() { return "org.kie.kogito.test.Person"; } public org.kie.kogito.codegen.data.Person readFrom(ProtoStreamReader reader) throws IOException { ... value.setEarnings((Array) (reader.readArray("earnings", java.io.Serializable.class))); // does not compile due to Array cast which is not valid value.setExpenses((Collection) (reader.readCollection("expenses", new java.util.ArrayList(), java.io.Serializable.class))); // does not compile due to Collection which is not valid } public void writeTo(ProtoStreamWriter writer, org.kie.kogito.codegen.data.Person t) throws IOException { ... writer.writeCollection("expenses", t.getExpenses(), java.io.Serializable.class); // does not compile due to missing cast } }