com.cudoy.framework.cache.redis.ObjectStream Maven / Gradle / Ivy
The newest version!
package com.cudoy.framework.cache.redis;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
public class ObjectStream extends ObjectInputStream{
protected ClassLoader classLoader = this.getClass().getClassLoader();
public ObjectStream(InputStream in) throws IOException {
super(in);
}
public ObjectStream(InputStream in, ClassLoader classLoader) throws IOException {
super(in);
this.classLoader = classLoader;
}
@Override
protected Class> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
String name = desc.getName();
try {
return Class.forName(name, false, this.classLoader);
}catch (Exception e){
return super.resolveClass(desc);
}
}
}