Login  Register

Re: Looks like a ClassLoader bug

Posted by Stephan Ewen on Jun 18, 2014; 1:12pm
URL: http://deprecated-apache-flink-mailing-list-archive.368.s1.nabble.com/Looks-like-a-ClassLoader-bug-tp336p440.html

I think I know where the issue is:

In "InstantiationUtil", can you change the method

public static Object deserializeObject(byte[] bytes, ClassLoader cl) throws
IOException, ClassNotFoundException {
ObjectInputStream oois = null;
try {
oois = new ClassLoaderObjectInputStream(new ByteArrayInputStream(bytes),
cl);
return oois.readObject();
} finally {
if (oois != null) {
oois.close();
}
}
}



to something like

public static Object deserializeObject(byte[] bytes, ClassLoader cl) throws
IOException, ClassNotFoundException {
ObjectInputStream oois = null;
 final ClassLoader old = Thread.currentThread().getContextClassLoader();
 try {
oois = new ClassLoaderObjectInputStream(new ByteArrayInputStream(bytes),
cl);
return oois.readObject();
}
finally {
Thread.currentThread().setContextClassLoader(old);
 if (oois != null) {
oois.close();
}
}
}