Uploaded image for project: 'Avro'
  1. Avro
  2. AVRO-1166

IDL return type of map<record> fails in schema processing

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.1
    • Fix Version/s: 1.7.2
    • Component/s: java
    • Labels:
      None

      Description

      An IDL construct such as ...

      Foo.idl
      protocol MyService {
          record Bar {
              int     count;
              string  message;
          }
      
          map<Bar> getBars();
      }
      

      generates run-time errors because of this code in SpecificData.java

      SpecificData.java lines 189-196
            } else if (Map.class.isAssignableFrom(raw)) {   // map
              java.lang.reflect.Type key = params[0];
              java.lang.reflect.Type value = params[1];
              if (!(type instanceof Class
                    && CharSequence.class.isAssignableFrom((Class)type)))
                throw new AvroTypeException("Map key class not CharSequence: "+key);
              return Schema.createMap(createSchema(value, names));
            } else {
      

      the issue is that CharSequence.class.isAssignableFrom((Class)type)) should really be CharSequence.class.isAssignableFrom((Class)key))

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gffletch George Fletcher
                Reporter:
                gffletch George Fletcher
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: