Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-8578

ProtoGenerator and MarshallerGenerator fails on arrays and collections of serializable classes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.36.0.Final
    • 1.33.0.Final
    • Core Engine
    • None
    • False
    • None
    • False
    • ---
    • ---
    • 2023 Week 09-11 (from Feb 27)
    • Important

    Description

      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
        }
      }

       

       

       

      Attachments

        Activity

          People

            cnicolai@redhat.com Cristiano Nicolai
            jmusacchio Juan Manuel Musacchio (Inactive)
            Marian Macik Marian Macik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: