nandini created AVRO-2974: ----------------------------- Summary: Env variable AVRO_DISABLE_ENUM_SYMBOL_VALIDATION is not honoured Key: AVRO-2974 URL: https://issues.apache.org/jira/browse/AVRO-2974 Project: Apache Avro Issue Type: Improvement Affects Versions: 1.9.0 Reporter: nandini
Our project upgraded from 1.8.2 to 1.9.1 We observed that it made the constraints checking more strict. https://my.diffend.io/gems/avro/1.8.2/1.9.1 Although the switch is provided, in Schema.Parser, it does not parse AVRO_DISABLE_ENUM_SYMBOL_VALIDATION in getValidateDefaults()) - which is why this environment variable if set still is not honoured. It is set in code to true. We can see it is parsed in data/lib/avro.rb file. A similar approach should be taken for java APIs so that migration may be easier. Ofcourse with a warning. I understand this is not a bug but an enhancement, but some users may want to by pass this check (which was thought out while introducing the environment variable I believe). POC: {code:java} public static void main(String[] args) throws Exception { //If env AVRO_DISABLE_FIELD_DEFAULT_VALIDATION=false then disable check //Else, it will default to true (as the behaviour in 1.9.1) Schema.Parser parser = new Schema.Parser(); System.out.println(parser.getValidateDefaults()); String disableEnv = System.getenv("AVRO_DISABLE_FIELD_DEFAULT_VALIDATION"); boolean disable = null != disableEnv?Boolean.parseBoolean(disableEnv): true; System.out.println(disable); parser.setValidateDefaults(disable); System.out.println(parser.getValidateDefaults()); Schema schema = parser.parse(schemaText); //Schema schema = parser.setValidateDefaults(false).parse(schemaText); System.out.println(schema); } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)