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

Date field cannot be used annotation processor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.4.4.Final, 4.5.0.Dev02
    • 4.4.3.Final
    • None
    • None
    • False
    • False

      I have a class that has a generated marshaller for it with a Date field. The generated marshaller code is not compilable. This is due to not assigning the date field to null;

      This can be reproduced by building this branch https://github.com/infinispan/infinispan/compare/main...wburns:protostream_date?expand=1 with `mvn clean install -pl core -am`

         @Override
         public org.infinispan.test.data.Person read(org.infinispan.protostream.ProtobufTagMarshaller.ReadContext $1) throws java.io.IOException {
            final org.infinispan.protostream.TagReader $in = $1.getReader();
            java.lang.String __v$1 = null;
            org.infinispan.test.data.Address __v$2 = null;
            java.util.Date __v$3;
      
            boolean done = false;
            while (!done) {
               final int tag = $in.readTag();
               switch (tag) {
                  case 0: {
                     done = true;
                     break;
                  }
                  case (1 << org.infinispan.protostream.descriptors.WireType.TAG_TYPE_NUM_BITS | org.infinispan.protostream.descriptors.WireType.WIRETYPE_LENGTH_DELIMITED): {
                     __v$1 = $in.readString();
                     break;
                  }
                  case (2 << org.infinispan.protostream.descriptors.WireType.TAG_TYPE_NUM_BITS | org.infinispan.protostream.descriptors.WireType.WIRETYPE_LENGTH_DELIMITED): {
                     if (__md$2 == null) __md$2 = ((org.infinispan.protostream.impl.SerializationContextImpl) $1.getSerializationContext()).getMarshallerDelegate(org.infinispan.test.data.Address.class);
                     int length = $in.readUInt32();
                     int oldLimit = $in.pushLimit(length);
                     __v$2 = (org.infinispan.test.data.Address) readMessage(__md$2, $1);
                     $in.checkLastTagWas(0);
                     $in.popLimit(oldLimit);
                     break;
                  }
                  case (3 << org.infinispan.protostream.descriptors.WireType.TAG_TYPE_NUM_BITS | org.infinispan.protostream.descriptors.WireType.WIRETYPE_FIXED64): {
                     __v$3 = new java.util.Date($in.readFixed64());
                     break;
                  }
                  default: {
                     if (!$in.skipField(tag)) done = true;
                  }
               }
            }
            return new org.infinispan.test.data.Person(__v$1, __v$2, __v$3);
         }
      

      The `java.util.Date __v$3;` line should be `java.util.Date __v$3 = null;` instead.

            ttarrant@redhat.com Tristan Tarrant
            wburns@redhat.com Will Burns
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: