Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

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

danielrdba7ba079e19
diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.java
index ead506a1e..ad2bea93a 100644
--- a/source/de/anomic/kelondro/kelondroRowCollection.java
+++ b/source/de/anomic/kelondro/kelondroRowCollection.java
@@ -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
// R is the right bound of the sequence, and outside of the sequence
// S is the bound of the sorted elements in the sequence
diff --git a/source/de/anomic/server/serverClassLoader.java b/source/de/anomic/server/serverClassLoader.java
index 7dcbdfb8b..ee43b0c87 100644
--- a/source/de/anomic/server/serverClassLoader.java
+++ b/source/de/anomic/server/serverClassLoader.java
@@ -45,8 +45,14 @@ import java.io.File;
import java.io.IOException;
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;
public serverClassLoader() {
@@ -77,7 +83,6 @@ public final class serverClassLoader extends ClassLoader {
} catch (IOException e) {
throw new ClassNotFoundException("Unable to resolve the classfile path");
}
-
// try to load the class
synchronized(classFileName.intern()) {
// 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
// we constructed the classfile for the only purpose to strip off the name:
- // get the class name out of the classfile
- String classname = classfile.getName();
- int p = classname.indexOf(".");
- classname = classname.substring(0, p);
+ /* get the class name out of the classfile */
+ // make classFileName relative
+ classFileName = classFileName.substring(classFileName.indexOf(baseDir) + baseDir.length());
+ // 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
//classfile = new File(classkey + ".class");
@@ -126,6 +150,7 @@ public final class serverClassLoader extends ClassLoader {
} catch (LinkageError ee) {
c = findLoadedClass(classname);
if (c!=null) return c;
+ serverLog.logSevere("ClassLoader", "class "+ classname +" not defined: "+ ee);
} catch (IOException ee) {
//System.out.println("INTERNAL ERROR2 in cachedClassLoader: " + ee.getMessage());
throw new ClassNotFoundException(classfile.toString());