From a4a078d429b746419dc7ee4bc4c97fad40c1bbc7 Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Fri, 19 Jan 2024 10:47:44 -0800 Subject: [PATCH 1/2] Work around java sdk issue 1973 --- features/update/task_failure/feature.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/update/task_failure/feature.java b/features/update/task_failure/feature.java index 964650aa..a2d79492 100644 --- a/features/update/task_failure/feature.java +++ b/features/update/task_failure/feature.java @@ -11,6 +11,8 @@ import io.temporal.workflow.UpdateMethod; import io.temporal.workflow.UpdateValidatorMethod; import io.temporal.workflow.Workflow; + +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Assertions; @@ -78,6 +80,16 @@ public Run execute(Runner runner) { Assertions.assertEquals("Failure", ((ApplicationFailure) e.getCause()).getType()); Assertions.assertEquals( "message='simulated 3', type='Failure', nonRetryable=false", e.getCause().getMessage()); + } catch (RuntimeException e) { + // TODO(https://github.com/temporalio/sdk-java/issues/1973) The SDK should be unwrapping the ExecutionException. + Assertions.assertTrue(e.getCause() instanceof ExecutionException); + ExecutionException ee = (ExecutionException) e.getCause(); + Assertions.assertTrue(ee.getCause() instanceof WorkflowUpdateException); + WorkflowUpdateException wue = (WorkflowUpdateException) ee.getCause(); + Assertions.assertTrue(wue.getCause() instanceof ApplicationFailure); + Assertions.assertEquals("Failure", ((ApplicationFailure) wue.getCause()).getType()); + Assertions.assertEquals( + "message='simulated 3', type='Failure', nonRetryable=false", wue.getCause().getMessage()); } // Check an update handle validator will fail on any exception From cbb4541ba2a94c2ef3b841100f981d76369bbaf2 Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Fri, 19 Jan 2024 11:12:45 -0800 Subject: [PATCH 2/2] Run spotless --- features/update/task_failure/feature.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/features/update/task_failure/feature.java b/features/update/task_failure/feature.java index a2d79492..6bfcd14d 100644 --- a/features/update/task_failure/feature.java +++ b/features/update/task_failure/feature.java @@ -11,7 +11,6 @@ import io.temporal.workflow.UpdateMethod; import io.temporal.workflow.UpdateValidatorMethod; import io.temporal.workflow.Workflow; - import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Assertions; @@ -81,7 +80,8 @@ public Run execute(Runner runner) { Assertions.assertEquals( "message='simulated 3', type='Failure', nonRetryable=false", e.getCause().getMessage()); } catch (RuntimeException e) { - // TODO(https://github.com/temporalio/sdk-java/issues/1973) The SDK should be unwrapping the ExecutionException. + // TODO(https://github.com/temporalio/sdk-java/issues/1973) The SDK should be unwrapping the + // ExecutionException. Assertions.assertTrue(e.getCause() instanceof ExecutionException); ExecutionException ee = (ExecutionException) e.getCause(); Assertions.assertTrue(ee.getCause() instanceof WorkflowUpdateException); @@ -89,7 +89,8 @@ public Run execute(Runner runner) { Assertions.assertTrue(wue.getCause() instanceof ApplicationFailure); Assertions.assertEquals("Failure", ((ApplicationFailure) wue.getCause()).getType()); Assertions.assertEquals( - "message='simulated 3', type='Failure', nonRetryable=false", wue.getCause().getMessage()); + "message='simulated 3', type='Failure', nonRetryable=false", + wue.getCause().getMessage()); } // Check an update handle validator will fail on any exception