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

Annotated Collection Class Method cannot be converted to Collection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.3.0.Alpha9, 4.3.0.Final
    • None
    • None
    • DataGrid Sprint #30, DataGrid Sprint #31, DataGrid Sprint #32, DataGrid Sprint #33, DataGrid Sprint #34, DataGrid Sprint #35, DataGrid Sprint #36, DataGrid Sprint #37, DataGrid Sprint #38, DataGrid Sprint #39

      Reproducing code

      public class MagicKeyStringFilter implements KeyValueFilter<MagicKey, String> {
      
         Map<MagicKey, String> allowedEntries;
      
         MagicKeyStringFilter() {}
      
         MagicKeyStringFilter(Map<MagicKey, String> allowedEntries) {
            this.allowedEntries = allowedEntries;
         }
      
         @ProtoField(number = 1, collectionImplementation = ArrayList.class)
         public List<MapPair> getMapEntries() {
            return new ArrayList<>();
         }
      
         public void setMapEntries(List<MapPair> entries) {
      // No-op but has influence on error
         }
      }
      
      public class MapPair {
      
         @ProtoField(number = 1)
         MagicKey key;
      
         @ProtoField(number = 2)
         String value;
      
         MapPair() {}
      
         MapPair(Map.Entry<MagicKey, String> entry) {
            this.key = entry.getKey();
            this.value = entry.getValue();
         }
      }
      
      core/target/generated-test-sources/test-annotations/org/infinispan/stream/MagicKeyStringFilter$___Marshaller89f891e2edf7d63eb676a6effb5379a47edc312b.java:[56,41] incompatible types: org.infinispan.stream.MapPair cannot be converted to java.util.Collection
      

      Generated marshaller code:

      /**
       * WARNING: Generated code!
       */
      @javax.annotation.Generated(value = "org.infinispan.protostream.annotations.impl.processor.AutoProtoSchemaBuilderAnnotationProcessor",
          comments = "Please do not edit this file!")
      @SuppressWarnings("unchecked")
      public final class MagicKeyStringFilter$___Marshaller89f891e2edf7d63eb676a6effb5379a47edc312b extends org.infinispan.protostream.annotations.impl.GeneratedMarshallerBase implements org.infinispan.protostream.RawProtobufMarshaller<org.infinispan.stream.MagicKeyStringFilter> {
      
         private org.infinispan.protostream.impl.BaseMarshallerDelegate __md$org$infinispan$stream$MapPair;
         
         @Override
         public Class<org.infinispan.stream.MagicKeyStringFilter> getJavaClass() { return org.infinispan.stream.MagicKeyStringFilter.class; }
         
         @Override
         public String getTypeName() { return "org.infinispan.test.MagicKeyStringFilter"; }
         
         @Override
         public org.infinispan.stream.MagicKeyStringFilter readFrom(org.infinispan.protostream.ImmutableSerializationContext $1, org.infinispan.protostream.RawProtoStreamReader $2) throws java.io.IOException {
            final org.infinispan.stream.MagicKeyStringFilter o = new org.infinispan.stream.MagicKeyStringFilter();
            java.util.ArrayList __c$mapEntries = new java.util.ArrayList();
            boolean done = false;
            while (!done) {
               final int tag = $2.readTag();
               switch (tag) {
                  case 0:
                     done = true;
                     break;
                  case 10:
                     {
                        if (__md$org$infinispan$stream$MapPair == null) __md$org$infinispan$stream$MapPair = ((org.infinispan.protostream.impl.SerializationContextImpl) $1).getMarshallerDelegate(org.infinispan.stream.MapPair.class);
                        int length = $2.readRawVarint32();
                        int oldLimit = $2.pushLimit(length);
                        org.infinispan.stream.MapPair v = (org.infinispan.stream.MapPair) readMessage(__md$org$infinispan$stream$MapPair, $2);
                        $2.checkLastTagWas(0);
                        $2.popLimit(oldLimit);
                        if (__c$mapEntries == null) __c$mapEntries = new java.util.ArrayList();
                        __c$mapEntries.add(v);
                     }
                     break;
                  default:
                     {
                        if (!$2.skipField(tag)) done = true;
                     }
               }
            }
            o.setMapEntries(__c$mapEntries);
            return o;
         }
         
         @Override
         public void writeTo(org.infinispan.protostream.ImmutableSerializationContext $1, org.infinispan.protostream.RawProtoStreamWriter $2, org.infinispan.stream.MagicKeyStringFilter $3) throws java.io.IOException {
            final org.infinispan.stream.MagicKeyStringFilter o = (org.infinispan.stream.MagicKeyStringFilter) $3;
            {
               final java.util.Collection c = (org.infinispan.stream.MapPair) o.getMapEntries();
               if (c != null) 
                  for (java.util.Iterator it = c.iterator(); it.hasNext(); ) {
                     final org.infinispan.stream.MapPair v = (org.infinispan.stream.MapPair) it.next();
                     {
                        if (__md$org$infinispan$stream$MapPair == null) __md$org$infinispan$stream$MapPair = ((org.infinispan.protostream.impl.SerializationContextImpl) $1).getMarshallerDelegate(org.infinispan.stream.MapPair.class);
                        writeNestedMessage(__md$org$infinispan$stream$MapPair, $2, 1, v);
                     }
                  }
            }
         }
      }
      

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

                Created:
                Updated:
                Resolved: