[crac] RFR: 8364449: [CRaC] Launch new main outside of the core C/R body [v2]
Radim Vansa
rvansa at openjdk.org
Fri Aug 8 10:41:35 UTC 2025
On Thu, 7 Aug 2025 08:00:50 GMT, Timofei Pushkin <tpushkin at openjdk.org> wrote:
>> test/jdk/jdk/crac/newArgs/FailedCheckpointRestoreTest.java line 104:
>>
>>> 102: System.out.println(RESTORE_MSG);
>>> 103: } catch (CheckpointException ex) {
>>> 104: if (variant != Variant.CHECKPOINT_EXCEPTION) {
>>
>> Could you rather check this using `jdk.test.lib.Asserts.*`?
>
> With asserts I'd need to format the the caught exception by myself to print it. Just using `ex.toString()` will not include all the info `throw` includes.
>
> The current way:
>
> Exception in thread "main" java.lang.IllegalStateException: Unexpected suppression message
> at FailedCheckpointRestoreTest.exec(FailedCheckpointRestoreTest.java:126)
> at jdk.test.lib.crac.CracTest.run(CracTest.java:165)
> at jdk.test.lib.crac.CracTest.main(CracTest.java:90)
> Caused by: jdk.crac.RestoreException
> Suppressed: java.lang.RuntimeException: restoreFail
> at FailedCheckpointRestoreTest$1.afterRestore(FailedCheckpointRestoreTest.java:99)
> at jdk.crac/jdk.crac.ResourceWrapper.afterRestore(ResourceWrapper.java:78)
> at java.base/jdk.internal.crac.mirror.impl.AbstractContext.invokeAfterRestore(AbstractContext.java:49)
> at java.base/jdk.internal.crac.mirror.impl.AbstractContext.afterRestore(AbstractContext.java:74)
> at jdk.crac/jdk.crac.ContextWrapper.afterRestore(ContextWrapper.java:61)
> at jdk.crac/jdk.crac.ResourceWrapper.afterRestore(ResourceWrapper.java:78)
> at java.base/jdk.internal.crac.mirror.impl.AbstractContext.invokeAfterRestore(AbstractContext.java:49)
> at java.base/jdk.internal.crac.mirror.impl.AbstractContext.afterRestore(AbstractContext.java:74)
> at java.base/jdk.internal.crac.mirror.Core.checkpointRestore1(Core.java:205)
> at java.base/jdk.internal.crac.mirror.Core.checkpointRestore(Core.java:287)
> at java.base/jdk.internal.crac.mirror.Core.checkpointRestore(Core.java:263)
> at jdk.crac/jdk.crac.Core.checkpointRestore(Core.java:73)
> at FailedCheckpointRestoreTest.exec(FailedCheckpointRestoreTest.java:106)
> at jdk.test.lib.crac.CracTest.run(CracTest.java:165)
> at jdk.test.lib.crac.CracTest.main(CracTest.java:90)
>
>
> Using `Asserts.assertEquals(restoreFail, ex.getSuppressed()[0].getMessage(), "Unexpected suppression message: " + ex)`:
>
> Exception in thread "main" java.lang.RuntimeException: Unexpected suppression message: jdk.crac.RestoreException expected: Failing on restore! but was: restoreFail
> at jdk.test.lib.Asserts.fail(Asserts.java:715)
> at jdk.test.lib.Asserts.assertEquals(Asserts.java:208)
> at FailedCheckpointRestoreTest.exec(FailedCheckpointRestoreTest.java:127)
> at jdk.test.lib.crac.CracT...
I haven't noticed the exception. I suppose if the asserts don't let you propagate the exception, you could add that variant:
/* Current method */
public static void assertEquals(Object lhs, Object rhs, String msg) {
if ((lhs != rhs) && ((lhs == null) || !(lhs.equals(rhs)))) {
fail((msg == null ? "assertEquals" : msg) + " expected: " + lhs + " but was: " + rhs);
}
}
/* Replace with this */
public static void assertEquals(Object lhs, Object rhs, String msg) {
assertEquals(lhs, rhs, msg, null);
}
public static void assertEquals(Object lhs, Object rhs, String msg, Throwable cause) {
if ((lhs != rhs) && ((lhs == null) || !(lhs.equals(rhs)))) {
fail((msg == null ? "assertEquals" : msg) + " expected: " + lhs + " but was: " + rhs, cause);
}
}
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/253#discussion_r2262593653
More information about the crac-dev
mailing list