diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/AbstractOmniscientTopLevelDataSetRegistrator.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/AbstractOmniscientTopLevelDataSetRegistrator.java index 531ceb4f3f67e41e701cdc980f73da85af74aef7..38657ef00122d66aee0b092764dec09b00ed4b0f 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/AbstractOmniscientTopLevelDataSetRegistrator.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/AbstractOmniscientTopLevelDataSetRegistrator.java @@ -26,7 +26,6 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.apache.log4j.Logger; -import org.python.core.PyException; import ch.systemsx.cisd.base.exceptions.InterruptedExceptionUnchecked; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; @@ -203,7 +202,7 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat } private final OmniscientTopLevelDataSetRegistratorState state; - + private boolean stopped; /** @@ -307,20 +306,19 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat { Throwable firstError = service.getEncounteredErrors().get(0); throw new EnvironmentFailureException("Could not process file " - + incomingDataSetFile.getName(), serializableException(firstError)); + + incomingDataSetFile.getName(), asSerializableException(firstError)); } } /** * Not all instances of PyExceptions are serializable, because they keep references to * non-serializable objects e.g. java.lang.reflect.Method. + * <p> + * Subclasses may need to override if they encounter other kinds of exceptions that cannot + * happen in this generic context. */ - private Throwable serializableException(Throwable throwable) + protected Throwable asSerializableException(Throwable throwable) { - if (throwable instanceof PyException) - { - return new RuntimeException(throwable.toString()); - } if (throwable instanceof UserFailureException) { return new RuntimeException(throwable.getMessage()); diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java index 549d76c6762d03f128ee43be386325beb1dfaad2..6af6cd19b6a65d5f30e1a489abe49ba41e54a3ed 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetHandler.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.etlserver.registrator; import java.io.File; import org.python.core.Py; +import org.python.core.PyException; import org.python.core.PyFunction; import org.python.util.PythonInterpreter; @@ -332,4 +333,16 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends PythonInterpreter interpreter = ((JythonDataSetRegistrationService<T>) service).interpreter; return interpreter; } + + @Override + protected Throwable asSerializableException(Throwable throwable) + { + if (throwable instanceof PyException) + { + return new RuntimeException(throwable.toString()); + } + + return super.asSerializableException(throwable); + } + }