From 92c1d58d9d005b596a294fea18bcf88871160305 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 1 Sep 2024 21:08:55 -0400 Subject: [PATCH] AVRO-4050: Deprecate MapUtil computeIfAbsent --- .../src/main/java/org/apache/avro/reflect/ReflectData.java | 2 +- .../main/java/org/apache/avro/specific/SpecificData.java | 2 +- .../avro/src/main/java/org/apache/avro/util/MapUtil.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java index 0c0b10478a5..a28bccd385d 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java +++ b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java @@ -839,7 +839,7 @@ public static Schema makeNullable(Schema schema) { // Return of this class and its superclasses to serialize. private static Field[] getCachedFields(Class recordClass) { - return MapUtil.computeIfAbsent(FIELDS_CACHE, recordClass, rc -> getFields(rc, true)); + return FIELDS_CACHE.computeIfAbsent(recordClass, rc -> getFields(rc, true)); } private static Field[] getFields(Class recordClass, boolean excludeJava) { 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 c30616e17a3..32bff471b7d 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 @@ -379,7 +379,7 @@ public Class getClass(Schema schema) { String name = schema.getFullName(); if (name == null) return null; - Class c = MapUtil.computeIfAbsent(classCache, name, n -> { + Class c = classCache.computeIfAbsent(name, n -> { try { return ClassUtils.forName(getClassLoader(), getClassName(schema)); } catch (ClassNotFoundException e) { diff --git a/lang/java/avro/src/main/java/org/apache/avro/util/MapUtil.java b/lang/java/avro/src/main/java/org/apache/avro/util/MapUtil.java index 1bdbfaf9a0a..23e4ea9c43e 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/util/MapUtil.java +++ b/lang/java/avro/src/main/java/org/apache/avro/util/MapUtil.java @@ -27,13 +27,13 @@ private MapUtil() { } /** - * A temporary workaround for Java 8 specific performance issue JDK-8161372 - * .
- * This class should be removed once we drop Java 8 support. + * A temporary workaround for Java 8 specific performance issue JDK-8161372. * * @see JDK-8161372 + * @deprecated As of JDK 1.9 this issue has been resolved. */ + @Deprecated public static V computeIfAbsent(ConcurrentMap map, K key, Function mappingFunction) { V value = map.get(key); if (value != null) {