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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.1
    • 1.7.2
    • java
    • 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

        1. AVRO-1166.patch
          2 kB
          Doug Cutting

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: