From 8cb61525b35bddef305ab9d7ebe68255d9ac3836 Mon Sep 17 00:00:00 2001 From: Christophe Le Saec Date: Mon, 11 Sep 2023 14:44:37 +0200 Subject: [PATCH] AVRO-3704: adapt validator --- lang/java/avro/src/main/java/org/apache/avro/Schema.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/Schema.java b/lang/java/avro/src/main/java/org/apache/avro/Schema.java index ef441a6ffcb..0e990fd40f9 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/Schema.java +++ b/lang/java/avro/src/main/java/org/apache/avro/Schema.java @@ -1584,7 +1584,7 @@ private static interface ParseFunction { } private Schema runParser(JsonParser parser, ParseFunction f) throws IOException { - boolean saved = validateNames.get(); + NameValidator saved = validateNames.get(); boolean savedValidateDefaults = VALIDATE_DEFAULTS.get(); try { validateNames.set(validate); @@ -1680,7 +1680,8 @@ public static Schema parse(String jsonSchema) { */ @Deprecated public static Schema parse(String jsonSchema, boolean validate) { - return new Parser().setValidate(validate).parse(jsonSchema); + final NameValidator validator = validate ? NameValidator.UTF_VALIDATOR : NameValidator.NO_VALIDATION; + return new Parser(validator).parse(jsonSchema); } static final Map PRIMITIVES = new HashMap<>();