From 5e77ec984524889670eecaf5d2c151b102535a1f Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Tue, 29 Dec 2009 10:54:27 +0000 Subject: [PATCH] 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 --- CHANGES.txt | 4 ++++ src/java/org/apache/lucene/util/AttributeSource.java | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 51eed575f9a..02c2b97e7ec 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/src/java/org/apache/lucene/util/AttributeSource.java b/src/java/org/apache/lucene/util/AttributeSource.java index 8dfeb46f311..adf7d888347 100644 --- a/src/java/org/apache/lucene/util/AttributeSource.java +++ b/src/java/org/apache/lucene/util/AttributeSource.java @@ -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 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()); }