avro-util icon indicating copy to clipboard operation
avro-util copied to clipboard

validate output of SpecificData.get().getDefaultValue(field) in getSpecificDefaultValue()

Open radai-rosenblatt opened this issue 3 years ago • 1 comments

scenario:

there's an enum class on the classpath of the same FQCN as an avro enum, but not generated by avro. avro (at least under 1.9) will return an instance of this non-avro enum out of:

  @Override
  public Object getSpecificDefaultValue(Schema.Field field) {
    return SpecificData.get().getDefaultValue(field);
  }

we could at least validate that the enum instance belongs to a class thats generated by avro, and save users some pain downstream

radai-rosenblatt avatar Nov 11 '21 17:11 radai-rosenblatt

could use ClassValue to efficiently cache the validation by the class of the result.

radai-rosenblatt avatar Nov 11 '21 17:11 radai-rosenblatt