-
Notifications
You must be signed in to change notification settings - Fork 683
Aligning internal caches with core framework patterns. #3073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments on places that would alter reloading behavior due to strong references that cannot be cleared when a GC would clear a ClassLoader
.
@@ -53,7 +53,7 @@ | |||
*/ | |||
class KotlinCopyMethod { | |||
|
|||
private static final Map<Class<?>, Optional<KotlinCopyMethod>> COPY_METHOD_CACHE = new ConcurrentReferenceHashMap<>(); | |||
private static final Map<Class<?>, Optional<KotlinCopyMethod>> COPY_METHOD_CACHE = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should remain ConcurrentReferenceHashMap
with default soft references to not hinder GC runs.
@@ -50,7 +50,7 @@ public class PropertyPath implements Streamable<PropertyPath> { | |||
private static final Pattern SPLITTER = Pattern.compile("(?:[%s]?([%s]*?[^%s]+))".replaceAll("%s", DELIMITERS)); | |||
private static final Pattern SPLITTER_FOR_QUOTED = Pattern.compile("(?:[%s]?([%s]*?[^%s]+))".replaceAll("%s", "\\.")); | |||
private static final Pattern NESTED_PROPERTY_PATTERN = Pattern.compile("\\p{Lu}[\\p{Ll}\\p{Nd}]*$"); | |||
private static final Map<Property, PropertyPath> cache = new ConcurrentReferenceHashMap<>(); | |||
private static final Map<Property, PropertyPath> cache = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also stay ConcurrentReferenceHashMap
as it is statically held.
@@ -141,7 +141,7 @@ private static boolean isDeleteMethod(String methodName) { | |||
*/ | |||
static class EventPublishingMethod { | |||
|
|||
private static Map<Class<?>, EventPublishingMethod> cache = new ConcurrentReferenceHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static cache should remain ConcurrentReferenceHashMap
@@ -46,7 +47,7 @@ | |||
*/ | |||
public abstract class ReturnedType { | |||
|
|||
private static final Map<CacheKey, ReturnedType> cache = new ConcurrentReferenceHashMap<>(32); | |||
private static final Map<CacheKey, ReturnedType> cache = new ConcurrentHashMap<>(32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remain ConcurrentReferenceHashMap
private static final Set<Function<Object, Object>> UNWRAPPERS = new HashSet<>(); | ||
private static final Set<Class<?>> ALLOWED_PAGEABLE_TYPES = new HashSet<>(); | ||
private static final Map<Class<?>, ExecutionAdapter> EXECUTION_ADAPTER = new HashMap<>(); | ||
private static final Map<Class<?>, Boolean> supportsCache = new ConcurrentReferenceHashMap<>(); | ||
private static final Map<Class<?>, ExecutionAdapter> EXECUTION_ADAPTER = new HashMap<>(3, 1f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remain ConcurrentReferenceHashMap
@@ -67,7 +67,7 @@ public abstract class NullableWrapperConverters { | |||
private static final Set<WrapperType> WRAPPER_TYPES = new HashSet<WrapperType>(); | |||
private static final Set<WrapperType> UNWRAPPER_TYPES = new HashSet<WrapperType>(); | |||
private static final Set<Converter<Object, Object>> UNWRAPPERS = new HashSet<Converter<Object, Object>>(); | |||
private static final Map<Class<?>, Boolean> supportsCache = new ConcurrentReferenceHashMap<>(); | |||
private static final Map<Class<?>, Boolean> supportsCache = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remain ConcurrentReferenceHashMap
@@ -45,7 +46,7 @@ | |||
public class ParameterTypes { | |||
|
|||
private static final TypeDescriptor OBJECT_DESCRIPTOR = TypeDescriptor.valueOf(Object.class); | |||
private static final ConcurrentMap<List<TypeDescriptor>, ParameterTypes> cache = new ConcurrentReferenceHashMap<>(); | |||
private static final ConcurrentMap<List<TypeDescriptor>, ParameterTypes> cache = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remain ConcurrentReferenceHashMap
@@ -32,7 +32,7 @@ | |||
*/ | |||
public abstract class ProxyUtils { | |||
|
|||
private static Map<Class<?>, Class<?>> USER_TYPES = new ConcurrentReferenceHashMap<>(); | |||
private static Map<Class<?>, Class<?>> USER_TYPES = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remain ConcurrentReferenceHashMap
@@ -70,7 +70,7 @@ public abstract class ReactiveWrappers { | |||
|
|||
public static final boolean IS_REACTIVE_AVAILABLE = Arrays.stream(ReactiveLibrary.values()) | |||
.anyMatch(ReactiveWrappers::isAvailable); | |||
private static final Map<Class<?>, Boolean> IS_REACTIVE_TYPE = new ConcurrentReferenceHashMap<>(); | |||
private static final Map<Class<?>, Boolean> IS_REACTIVE_TYPE = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remain ConcurrentReferenceHashMap
bad76ca
to
452fdff
Compare
That's merged and polished now. |
Also initialize maps & sets with size where possible.
Closes: #3067