mirror of https://github.com/apache/activemq.git
Apply patch for https://issues.apache.org/activemq/browse/AMQ-1584
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@628710 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2747573f66
commit
213c3ae379
|
@ -21,11 +21,13 @@ import java.io.InputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectStreamClass;
|
import java.io.ObjectStreamClass;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ClassLoadingAwareObjectInputStream extends ObjectInputStream {
|
public class ClassLoadingAwareObjectInputStream extends ObjectInputStream {
|
||||||
|
|
||||||
private static final ClassLoader FALLBACK_CLASS_LOADER = ClassLoadingAwareObjectInputStream.class.getClassLoader();
|
private static final ClassLoader FALLBACK_CLASS_LOADER = ClassLoadingAwareObjectInputStream.class.getClassLoader();
|
||||||
|
/** <p>Maps primitive type names to corresponding class objects.</p> */
|
||||||
|
private static final HashMap<String, Class> primClasses = new HashMap<String, Class>(8, 1.0F);
|
||||||
public ClassLoadingAwareObjectInputStream(InputStream in) throws IOException {
|
public ClassLoadingAwareObjectInputStream(InputStream in) throws IOException {
|
||||||
super(in);
|
super(in);
|
||||||
}
|
}
|
||||||
|
@ -49,12 +51,32 @@ public class ClassLoadingAwareObjectInputStream extends ObjectInputStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class load(String className, ClassLoader cl) throws ClassNotFoundException {
|
private Class load(String className, ClassLoader cl)
|
||||||
|
throws ClassNotFoundException {
|
||||||
try {
|
try {
|
||||||
return Class.forName(className, false, cl);
|
return Class.forName(className, false, cl);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
return Class.forName(className, false, FALLBACK_CLASS_LOADER);
|
final Class clazz = (Class) primClasses.get(className);
|
||||||
|
if (clazz != null) {
|
||||||
|
return clazz;
|
||||||
|
} else {
|
||||||
|
return Class.forName(className, false, FALLBACK_CLASS_LOADER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
primClasses.put("boolean", boolean.class);
|
||||||
|
primClasses.put("byte", byte.class);
|
||||||
|
primClasses.put("char", char.class);
|
||||||
|
primClasses.put("short", short.class);
|
||||||
|
primClasses.put("int", int.class);
|
||||||
|
primClasses.put("long", long.class);
|
||||||
|
primClasses.put("float", float.class);
|
||||||
|
primClasses.put("double", double.class);
|
||||||
|
primClasses.put("void", void.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue