You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AnnotationUtils should use threadsafe ConcurrentMap (contention) [SPR-12878] #17476
private static final Map<Class<?>, Boolean> annotatedInterfaceCache = new WeakHashMap<Class<?>, Boolean>();
...
private static boolean isInterfaceWithAnnotatedMethods(Class<?> iface) {
synchronized (annotatedInterfaceCache) {
Boolean flag = annotatedInterfaceCache.get(iface);
is a point of contention in my app and should be replaced by something like ConcurrentSkipListMap (but not ConcurrentHashMap because ConcurrentSkipListMap uses 1/10th the memory initially). Here's a Comparator for WeakReference:
import java.lang.ref.WeakReference;
import java.util.Comparator;
import org.springframework.util.ObjectUtils;
public class WeakReferenceClassComparator implements Comparator<WeakReference<Class>> {
@Override
public int compare(WeakReference<Class> o1, WeakReference<Class> o2) {
if (o1.get() == null && o2.get() == null) {
return 0;
}
return new Integer(ObjectUtils.nullSafeHashCode(o1.get())).compareTo(ObjectUtils.nullSafeHashCode(o2.get()));
}
}
Activity
spring-projects-issues commentedon Apr 1, 2015
Juergen Hoeller commented
This has been addressed in the 4.1 line already, as part of #16501, using our own
ConcurrentReferenceHashMapthere now.Note that the 4.0.x line has ended in the meantime, with no further releases planned. Please upgrade to 4.1.6 right away!
Juergen
spring-projects-issues commentedon Apr 1, 2015
Johann Burkard commented
Thanks for the update, Jürgen. I'll tro to update.