fixed NPE seen with queues_p.xml (serverClassLoader finds already loaded classes)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4952 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
danielr 17 years ago
parent c5e5c554d2
commit dba7ba079e

@ -615,7 +615,7 @@ public class kelondroRowCollection {
} }
} }
private final int partition(int L, int R, int S, byte[] swapspace) { final int partition(int L, int R, int S, byte[] swapspace) {
// L is the first element in the sequence // L is the first element in the sequence
// R is the right bound of the sequence, and outside of the sequence // R is the right bound of the sequence, and outside of the sequence
// S is the bound of the sorted elements in the sequence // S is the bound of the sorted elements in the sequence

@ -45,8 +45,14 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
public final class serverClassLoader extends ClassLoader { import de.anomic.server.logging.serverLog;
public final class serverClassLoader extends ClassLoader {
/**
* directory of class files
*/
private static final String HTROOT = "htroot/";
private final static String baseDir = System.getProperty("user.dir");
private final HashMap<File, Class<?>> classes; private final HashMap<File, Class<?>> classes;
public serverClassLoader() { public serverClassLoader() {
@ -77,7 +83,6 @@ public final class serverClassLoader extends ClassLoader {
} catch (IOException e) { } catch (IOException e) {
throw new ClassNotFoundException("Unable to resolve the classfile path"); throw new ClassNotFoundException("Unable to resolve the classfile path");
} }
// try to load the class // try to load the class
synchronized(classFileName.intern()) { synchronized(classFileName.intern()) {
// first try: take the class out of the cache, denoted by the classname // first try: take the class out of the cache, denoted by the classname
@ -89,10 +94,29 @@ public final class serverClassLoader extends ClassLoader {
// this file cannot exist for real, since we stripped off the .class // this file cannot exist for real, since we stripped off the .class
// we constructed the classfile for the only purpose to strip off the name: // we constructed the classfile for the only purpose to strip off the name:
// get the class name out of the classfile /* get the class name out of the classfile */
String classname = classfile.getName(); // make classFileName relative
int p = classname.indexOf("."); classFileName = classFileName.substring(classFileName.indexOf(baseDir) + baseDir.length());
classname = classname.substring(0, p); // special source dirs
if(classFileName.contains(HTROOT)) {
classFileName = classFileName.substring(classFileName.indexOf(HTROOT) + HTROOT.length());
}
String packge = "";
final int endPackage = classFileName.lastIndexOf(File.separatorChar);
if(endPackage != -1) {
packge = classFileName.substring(0, endPackage);
// the files under htroot/yacy are all in 'default package'!
if(packge.startsWith("yacy")) {
packge = "";
}
if(packge.length() > 0) {
packge.replace(File.separatorChar, '.');
packge += ".";
}
}
int p = classFileName.indexOf(".", endPackage);
String classname = packge + classFileName.substring(endPackage + 1, p);
// now that we have the name, we can create the real class file // now that we have the name, we can create the real class file
//classfile = new File(classkey + ".class"); //classfile = new File(classkey + ".class");
@ -126,6 +150,7 @@ public final class serverClassLoader extends ClassLoader {
} catch (LinkageError ee) { } catch (LinkageError ee) {
c = findLoadedClass(classname); c = findLoadedClass(classname);
if (c!=null) return c; if (c!=null) return c;
serverLog.logSevere("ClassLoader", "class "+ classname +" not defined: "+ ee);
} catch (IOException ee) { } catch (IOException ee) {
//System.out.println("INTERNAL ERROR2 in cachedClassLoader: " + ee.getMessage()); //System.out.println("INTERNAL ERROR2 in cachedClassLoader: " + ee.getMessage());
throw new ClassNotFoundException(classfile.toString()); throw new ClassNotFoundException(classfile.toString());

Loading…
Cancel
Save