Skip to content

Commit

Permalink
Minor addition to DeserializerCache
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 31, 2023
1 parent ae952a6 commit c4303bb
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.databind.util.ClassUtil;
import com.fasterxml.jackson.databind.util.Converter;
import com.fasterxml.jackson.databind.util.LRUMap;
import com.fasterxml.jackson.databind.util.LookupCache;

/**
* Class that defines caching layer between callers (like
Expand All @@ -34,14 +35,14 @@ public final class DeserializerCache
* specifically, ones that are expensive to construct.
* This currently means bean, Enum and container deserializers.
*/
final protected LRUMap<JavaType, JsonDeserializer<Object>> _cachedDeserializers;
protected final LookupCache<JavaType, JsonDeserializer<Object>> _cachedDeserializers;

/**
* During deserializer construction process we may need to keep track of partially
* completed deserializers, to resolve cyclic dependencies. This is the
* map used for storing deserializers before they are fully complete.
*/
final protected HashMap<JavaType, JsonDeserializer<Object>> _incompleteDeserializers
protected final HashMap<JavaType, JsonDeserializer<Object>> _incompleteDeserializers
= new HashMap<JavaType, JsonDeserializer<Object>>(8);

/*
Expand All @@ -55,8 +56,14 @@ public DeserializerCache() {
}

public DeserializerCache(int maxSize) {
int initial = Math.min(64, maxSize>>2);
_cachedDeserializers = new LRUMap<>(initial, maxSize);
this(new LRUMap<>(Math.min(64, maxSize>>2), maxSize));
}

/**
* @since 2.16
*/
public DeserializerCache(LookupCache<JavaType, JsonDeserializer<Object>> cache) {
_cachedDeserializers = cache;
}

/*
Expand Down

0 comments on commit c4303bb

Please sign in to comment.