diff --git a/temporal-sdk/src/test/java/io/temporal/client/functional/MetricsTest.java b/temporal-sdk/src/test/java/io/temporal/client/functional/MetricsTest.java index 98fddf17c..ce353e940 100644 --- a/temporal-sdk/src/test/java/io/temporal/client/functional/MetricsTest.java +++ b/temporal-sdk/src/test/java/io/temporal/client/functional/MetricsTest.java @@ -63,6 +63,7 @@ public class MetricsTest { @Before public void setUp() { + registry.clear(); tagsNamespaceQueue = replaceTags(TAGS_NAMESPACE, MetricsTag.TASK_QUEUE, testWorkflowRule.getTaskQueue()); } diff --git a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java index 61d29ece6..c667c47a2 100644 --- a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java +++ b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java @@ -488,14 +488,16 @@ public void completeWorkflowTask( if (unhandledCommand(request) || unhandledMessages(request)) { // Fail the workflow task if there are new events or messages and a command tries to - // complete the - // workflow + // complete the workflow. Record the failure in history, then throw an error to the + // caller (matching real server behavior). failWorkflowTaskWithAReason( WorkflowTaskFailedCause.WORKFLOW_TASK_FAILED_CAUSE_UNHANDLED_COMMAND, null, ctx, request, false); + ctx.setExceptionIfEmpty( + Status.INVALID_ARGUMENT.withDescription("UnhandledCommand").asRuntimeException()); return; }