Skip to content

Commit

Permalink
AVRO-4050: Deprecate MapUtil computeIfAbsent
Browse files Browse the repository at this point in the history
  • Loading branch information
belugabehr committed Sep 2, 2024
1 parent c7b79bf commit ae26c3e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.avro.specific.FixedSize;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.ClassUtils;
import org.apache.avro.util.MapUtil;

import java.io.IOException;
import java.lang.annotation.Annotation;
Expand Down Expand Up @@ -839,7 +838,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.avro.io.DecoderFactory;
import org.apache.avro.io.EncoderFactory;
import org.apache.avro.util.ClassUtils;
import org.apache.avro.util.MapUtil;
import org.apache.avro.util.SchemaUtil;
import org.apache.avro.util.internal.ClassValueCache;

Expand Down Expand Up @@ -379,7 +378,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ private MapUtil() {
}

/**
* A temporary workaround for Java 8 specific performance issue JDK-8161372
* .<br>
* This class should be removed once we drop Java 8 support.
* A temporary workaround for Java 8 specific performance issue JDK-8161372.
*
* @see <a href=
* "https://bugs.openjdk.java.net/browse/JDK-8161372">JDK-8161372</a>
* @deprecated As of JDK 1.9 this issue has been resolved.
*/
@Deprecated
public static <K, V> V computeIfAbsent(ConcurrentMap<K, V> map, K key, Function<K, V> mappingFunction) {
V value = map.get(key);
if (value != null) {
Expand Down

0 comments on commit ae26c3e

Please sign in to comment.