|
|
@ -40,14 +40,22 @@ public class SerializationCodec extends BaseCodec {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Object decode(ByteBuf buf, State state) throws IOException {
|
|
|
|
public Object decode(ByteBuf buf, State state) throws IOException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ByteBufInputStream in = new ByteBufInputStream(buf);
|
|
|
|
//set thread context class loader to be the classLoader variable as there could be reflection
|
|
|
|
ObjectInputStream inputStream;
|
|
|
|
//done while reading from input stream which reflection will use thread class loader to load classes on demand
|
|
|
|
if (classLoader != null) {
|
|
|
|
ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
|
|
|
|
inputStream = new CustomObjectInputStream(classLoader, in);
|
|
|
|
try {
|
|
|
|
} else {
|
|
|
|
ByteBufInputStream in = new ByteBufInputStream(buf);
|
|
|
|
inputStream = new ObjectInputStream(in);
|
|
|
|
ObjectInputStream inputStream;
|
|
|
|
|
|
|
|
if (classLoader != null) {
|
|
|
|
|
|
|
|
Thread.currentThread().setContextClassLoader(classLoader);
|
|
|
|
|
|
|
|
inputStream = new CustomObjectInputStream(classLoader, in);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
inputStream = new ObjectInputStream(in);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return inputStream.readObject();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
Thread.currentThread().setContextClassLoader(currentThreadClassLoader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return inputStream.readObject();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|