mirror of
https://github.com/wassname/ray.git
synced 2026-07-21 12:50:45 +08:00
Fix Java exception serialization (#10568)
This commit is contained in:
@@ -12,4 +12,12 @@ public class RayActorException extends RayException {
|
||||
super("The actor died unexpectedly before finishing this task.");
|
||||
}
|
||||
|
||||
public RayActorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public RayActorException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,4 +9,12 @@ public class RayWorkerException extends RayException {
|
||||
super("The worker died unexpectedly while executing this task.");
|
||||
}
|
||||
|
||||
public RayWorkerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public RayWorkerException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import io.ray.api.id.ObjectId;
|
||||
*/
|
||||
public class UnreconstructableException extends RayException {
|
||||
|
||||
public final ObjectId objectId;
|
||||
public ObjectId objectId;
|
||||
|
||||
public UnreconstructableException(ObjectId objectId) {
|
||||
super(String.format(
|
||||
@@ -20,4 +20,12 @@ public class UnreconstructableException extends RayException {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
public UnreconstructableException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UnreconstructableException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ import io.ray.api.ActorHandle;
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.function.RayFunc0;
|
||||
import io.ray.api.id.ObjectId;
|
||||
import io.ray.runtime.exception.RayActorException;
|
||||
import io.ray.runtime.exception.RayTaskException;
|
||||
import io.ray.runtime.exception.RayWorkerException;
|
||||
import io.ray.runtime.exception.UnreconstructableException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
@@ -145,5 +147,24 @@ public class FailureTest extends BaseTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testExceptionSerialization() {
|
||||
RayTaskException ex1 = Assert.expectThrows(RayTaskException.class, () -> {
|
||||
Ray.put(new RayTaskException("xxx", new RayActorException())).get();
|
||||
});
|
||||
Assert.assertEquals(ex1.getCause().getClass(), RayActorException.class);
|
||||
RayTaskException ex2 = Assert.expectThrows(RayTaskException.class, () -> {
|
||||
Ray.put(new RayTaskException("xxx", new RayWorkerException())).get();
|
||||
});
|
||||
Assert.assertEquals(ex2.getCause().getClass(), RayWorkerException.class);
|
||||
|
||||
ObjectId objectId = ObjectId.fromRandom();
|
||||
RayTaskException ex3 = Assert.expectThrows(RayTaskException.class, () -> {
|
||||
Ray.put(new RayTaskException("xxx", new UnreconstructableException(objectId)))
|
||||
.get();
|
||||
});
|
||||
Assert.assertEquals(ex3.getCause().getClass(), UnreconstructableException.class);
|
||||
Assert.assertEquals(((UnreconstructableException) ex3.getCause()).objectId, objectId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user