LUCENE-2182: DEFAULT_ATTRIBUTE_FACTORY was failing to load implementation class when interface was loaded by a different class loader

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@894348 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-12-29 10:54:27 +00:00
parent 45ffab1cd5
commit 5e77ec9845
2 changed files with 10 additions and 3 deletions

View File

@ -83,6 +83,10 @@ Bug fixes
* LUCENE-2158: At high indexing rates, NRT reader could temporarily
lose deletions. (Mike McCandless)
* LUCENE-2182: DEFAULT_ATTRIBUTE_FACTORY was failing to load
implementation class when interface was loaded by a different
class loader. (Uwe Schindler, reported on java-user by Ahmed El-dawy)
New features
* LUCENE-2128: Parallelized fetching document frequencies during weight

View File

@ -64,9 +64,9 @@ public class AttributeSource {
try {
return getClassForInterface(attClass).newInstance();
} catch (InstantiationException e) {
throw new IllegalArgumentException("Could not instantiate class " + attClass.getName());
throw new IllegalArgumentException("Could not instantiate implementing class for " + attClass.getName());
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Could not instantiate class " + attClass.getName());
throw new IllegalArgumentException("Could not instantiate implementing class for " + attClass.getName());
}
}
@ -75,7 +75,10 @@ public class AttributeSource {
Class<? extends AttributeImpl> clazz = attClassImplMap.get(attClass);
if (clazz == null) {
try {
attClassImplMap.put(attClass, clazz = Class.forName(attClass.getName() + "Impl").asSubclass(AttributeImpl.class));
attClassImplMap.put(attClass,
clazz = Class.forName(attClass.getName() + "Impl", true, attClass.getClassLoader())
.asSubclass(AttributeImpl.class)
);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find implementing class for " + attClass.getName());
}