From 80400781a796bc0e90dd8ea1db42234926db33e9 Mon Sep 17 00:00:00 2001 From: belugabehr <12578579+belugabehr@users.noreply.github.com> Date: Sun, 29 Sep 2024 08:20:46 -0400 Subject: [PATCH] AVRO-4066: Use JDK isBlank Method (#3182) --- .../apache/avro/specific/SpecificData.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java index a9dbbcbb5b6..c7b5eaed8a7 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java +++ b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java @@ -324,7 +324,7 @@ public static String mangleMethod(String word, boolean isError) { * Utility for template use. Adds a dollar sign to reserved words. */ public static String mangle(String word, Set reservedWords, boolean isMethod) { - if (isBlank(word)) { + if (word == null || word.isBlank()) { return word; } if (word.contains(".")) { @@ -354,21 +354,6 @@ protected static String unmangle(String word) { return word; } - private static boolean isBlank(CharSequence cs) { - int strLen = cs == null ? 0 : cs.length(); - if (strLen == 0) { - return true; - } else { - for (int i = 0; i < strLen; ++i) { - if (!Character.isWhitespace(cs.charAt(i))) { - return false; - } - } - - return true; - } - } - /** Return the class that implements a schema, or null if none exists. */ public Class getClass(Schema schema) { switch (schema.getType()) { @@ -452,7 +437,7 @@ private Class getWrapper(Schema schema) { public static String getClassName(Schema schema) { String namespace = schema.getNamespace(); String name = schema.getName(); - if (namespace == null || "".equals(namespace)) + if (namespace == null || namespace.isEmpty()) return name; String dot = namespace.endsWith("$") ? "" : "."; // back-compatibly handle $ return mangle(namespace) + dot + mangleTypeIdentifier(name);