Index: CHANGES.txt =================================================================== --- CHANGES.txt (revision 908867) +++ CHANGES.txt (working copy) @@ -107,6 +107,11 @@ * LUCENE-2249: ParallelMultiSearcher should shut down thread pool on close. (Martin Traverso via Uwe Schindler) +* LUCENE-2260: Fixed AttributeSource to not hold a strong + reference to the Attribute/AttributeImpl classes which prevents + unloading of custom attributes loaded by other classloaders + (e.g. in Solr plugins). (Uwe Schindler) + New features * LUCENE-2128: Parallelized fetching document frequencies during weight Index: src/java/org/apache/lucene/util/AttributeSource.java =================================================================== --- src/java/org/apache/lucene/util/AttributeSource.java (revision 908867) +++ src/java/org/apache/lucene/util/AttributeSource.java (working copy) @@ -21,7 +21,7 @@ import java.util.NoSuchElementException; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.IdentityHashMap; +import java.util.WeakHashMap; import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; @@ -54,8 +54,8 @@ public static final AttributeFactory DEFAULT_ATTRIBUTE_FACTORY = new DefaultAttributeFactory(); private static final class DefaultAttributeFactory extends AttributeFactory { - private static final IdentityHashMap, Class> attClassImplMap = - new IdentityHashMap, Class>(); + private static final WeakHashMap, Class> attClassImplMap = + new WeakHashMap, Class>(); private DefaultAttributeFactory() {} @@ -173,8 +173,8 @@ } /** a cache that stores all interfaces for known implementation classes for performance (slow reflection) */ - private static final IdentityHashMap,LinkedList>> knownImplClasses = - new IdentityHashMap,LinkedList>>(); + private static final WeakHashMap,LinkedList>> knownImplClasses = + new WeakHashMap,LinkedList>>(); /** Expert: Adds a custom AttributeImpl instance with one or more Attribute interfaces. *

Please note: It is not guaranteed, that att is added to Index: src/java/org/apache/lucene/util/VirtualMethod.java =================================================================== --- src/java/org/apache/lucene/util/VirtualMethod.java (revision 908867) +++ src/java/org/apache/lucene/util/VirtualMethod.java (working copy) @@ -20,7 +20,7 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.HashSet; -import java.util.IdentityHashMap; +import java.util.WeakHashMap; import java.util.Set; /** @@ -64,8 +64,8 @@ private final Class baseClass; private final String method; private final Class[] parameters; - private final IdentityHashMap, Integer> cache = - new IdentityHashMap, Integer>(); + private final WeakHashMap, Integer> cache = + new WeakHashMap, Integer>(); /** * Creates a new instance for the given {@code baseClass} and method declaration.