mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 22:48:34 +00:00
Made AbstractReplicableWithObjectInputStream more robust
This commit is contained in:
@@ -44,8 +44,7 @@ Import-Package: javax.ws.rs;version="1.1.1",
|
||||
Web-ContextPath: /windestimation
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.sap.sailing.windestimation,
|
||||
com.sap.sailing.windestimation.integration
|
||||
Export-Package: com.sap.sailing.windestimation
|
||||
Bundle-ClassPath: lib/smile-core-1.5.2.jar,
|
||||
lib/smile-data-1.5.2.jar,
|
||||
lib/smile-graph-1.5.2.jar,
|
||||
|
||||
+10
-4
@@ -106,7 +106,7 @@ public abstract class AbstractReplicableWithObjectInputStream<S, O extends Opera
|
||||
|
||||
@Override
|
||||
public ObjectInputStream createObjectInputStreamResolvingAgainstCache(InputStream is) throws IOException {
|
||||
ObjectInputStream ois = new BundleObjectInputStream(is);
|
||||
ObjectInputStream ois = new ObjectInputStreamWithContextClassLoaderAsResolver(is);
|
||||
return ois;
|
||||
}
|
||||
|
||||
@@ -147,15 +147,21 @@ public abstract class AbstractReplicableWithObjectInputStream<S, O extends Opera
|
||||
* @author Vladislav Chumak (D069712)
|
||||
*
|
||||
*/
|
||||
private class BundleObjectInputStream extends ObjectInputStream {
|
||||
private class ObjectInputStreamWithContextClassLoaderAsResolver extends ObjectInputStream {
|
||||
|
||||
public BundleObjectInputStream(InputStream in) throws IOException {
|
||||
public ObjectInputStreamWithContextClassLoaderAsResolver(InputStream in) throws IOException {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
|
||||
return super.resolveClass(desc);
|
||||
String name = desc.getName();
|
||||
try {
|
||||
return Class.forName(name, /* initialize */true, Thread.currentThread().getContextClassLoader());
|
||||
} catch (ClassNotFoundException ex) {
|
||||
// fall back on super class in order to load primitive types
|
||||
return super.resolveClass(desc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user