Uploaded image for project: 'ProtoStream'
  1. ProtoStream
  2. IPROTO-120

Null collection fields always unmarshalled as empty collection implementation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • None
    • None

    Description

      The following Pojo always returns an empty collection after being unmarshalled, regardless of whether stringList was null or empty when marshalled.

      public class SomePojo {
      
         @ProtoField(number = 1, collectionImplementation = ArrayList.class)
         final List<String> stringList;
      
         @ProtoFactory
         public SomePojo(List<String> stringList) {
            this.stringList = stringList;
         }
      }
      

      This is because the generated marshaller always creates the collection instance before attempting to read the collection content:

            java.util.ArrayList __c$1 = new java.util.ArrayList();
            boolean done = false;
            while (!done) {
               final int tag = $2.readTag();
               switch (tag) {
                  case 0:
                     done = true;
                     break;
                  case 10: {
                     java.lang.String __v$1 = $2.readString();
                     __c$1.add(__v$1);
                     break;
                  }
                  default: {
                     if (!$2.skipField(tag)) done = true;
                  }
               }
            }
            
            return new org.infinispan.query.dsl.embedded.testdomain.hsearch.SomePojo(__c$1);
      

      Attachments

        Issue Links

          Activity

            People

              anistor Adrian Nistor (Inactive)
              remerson@redhat.com Ryan Emerson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: