sdk-java
sdk-java copied to clipboard
Workflow should be able to ignore CancellationFailure and finish successfully
Expected Behavior
Workflow code should be able to catch CancellationFailure, handle or ignore it and be able to finish executing successfully.
Test https://github.com/Spikhalskiy/java-sdk/commit/eada50399b6d24c77d4b6e37cd500907594a189a#diff-a2baafb2fd6213bafb49077bd60c8efeedc6c15df86437e9c8e2ef87ce23625cR58
expected to pass
Actual Behavior
Test fails. Workflow doesn't get a chance to fully swallow and ignore CancellationFailure and is forced to finish with EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED
We did the exact thing in TypeScript a while ago. We only complete with cancelled if cancellation of the Workflow was requested and the workflow propagates an exception that is considered cancellation. https://github.com/temporalio/sdk-typescript/blob/733b01ee9913c255cea8913222c1232bf1bda3a4/packages/workflow/src/errors.ts#L38
After discussion with @mfateev we decided that it's too much of the breaking change to the current concept of scopes. It's not a bug, it's designed this way right now. Once the scope is requested to be canceled, it's considered canceled new commands have to be scheduled in the detached scope. We may reconsider this decision and design in the future, but when we design JavaSDK 2.x which will not strive to maintain compatibility and will revisit all the existing concepts and APIs.