Fixed ClassNotFound issue in replication of

WindEstimationModelsUpdateOperation
This commit is contained in:
Vladislav Chumak
2019-02-19 22:32:10 +01:00
parent 44bd77f23a
commit 34644bf758
@@ -3,6 +3,7 @@ package com.sap.sailing.windestimation.integration;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -105,7 +106,7 @@ public abstract class AbstractReplicableWithObjectInputStream<S, O extends Opera
@Override
public ObjectInputStream createObjectInputStreamResolvingAgainstCache(InputStream is) throws IOException {
ObjectInputStream ois = new ObjectInputStream(is);
ObjectInputStream ois = new BundleObjectInputStream(is);
return ois;
}
@@ -139,4 +140,24 @@ public abstract class AbstractReplicableWithObjectInputStream<S, O extends Opera
this.operationsSentToMasterForReplication.add(operation);
}
/**
* Custom {@link ObjectInputStream} which is necessary in OSGI context in order to load the class
* {@link WindEstimationModelsUpdateOperation} without {@link ClassNotFoundException}.
*
* @author Vladislav Chumak (D069712)
*
*/
private class BundleObjectInputStream extends ObjectInputStream {
public BundleObjectInputStream(InputStream in) throws IOException {
super(in);
}
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
return super.resolveClass(desc);
}
}
}