'Avro array with java.util.set

I have an avro schema defined as follows:

record Test {
    @java-class("java.util.HashSet") array<string> setOfStrings;
}

According to the example here, this should generate a set. However, when I generate the code using avro gradle plugin, the generated class still uses a list.

@org.apache.avro.specific.AvroGenerated
public class Test extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
  private static final long serialVersionUID = -5422584550191091828L;


  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Test\",\"namespace\":\"somenamespace.avro\",\"fields\":[{\"name\":\"setOfStrings\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"java-class\":\"java.util.Set\"}}]}");
  public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }

  ....

  private java.util.List<java.lang.String> setOfStrings;

I also tried with java.util.Set instead of HashSet. How do I generate a set of strings with java-class annotation in avro?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source