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);