Skip to content

Commit 08d6089

Browse files
Remove old workflow run operation token format (#2486)
1 parent afb0183 commit 08d6089

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

temporal-sdk/src/main/java/io/temporal/internal/nexus/OperationTokenUtil.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ public class OperationTokenUtil {
3737
/**
3838
* Load a workflow run operation token from an operation token.
3939
*
40-
* @throws FallbackToWorkflowIdException if the operation token is not a workflow run token
4140
* @throws IllegalArgumentException if the operation token is invalid
4241
*/
43-
public static WorkflowRunOperationToken loadWorkflowRunOperationToken(String operationToken)
44-
throws FallbackToWorkflowIdException {
42+
public static WorkflowRunOperationToken loadWorkflowRunOperationToken(String operationToken) {
4543
WorkflowRunOperationToken token;
4644
try {
4745
JavaType reference = mapper.getTypeFactory().constructType(WorkflowRunOperationToken.class);
4846
token = mapper.readValue(decoder.decode(operationToken), reference);
4947
} catch (Exception e) {
50-
throw new FallbackToWorkflowIdException("Failed to parse operation token: " + e.getMessage());
48+
throw new IllegalArgumentException("Failed to parse operation token: " + e.getMessage());
5149
}
5250
if (!token.getType().equals(OperationTokenType.WORKFLOW_RUN)) {
5351
throw new IllegalArgumentException(
@@ -68,16 +66,7 @@ public static WorkflowRunOperationToken loadWorkflowRunOperationToken(String ope
6866
* @throws IllegalArgumentException if the operation token is invalid
6967
*/
7068
public static String loadWorkflowIdFromOperationToken(String operationToken) {
71-
try {
72-
WorkflowRunOperationToken token = loadWorkflowRunOperationToken(operationToken);
73-
return token.getWorkflowId();
74-
} catch (OperationTokenUtil.FallbackToWorkflowIdException e) {
75-
// Previous versions of the SDK simply used the workflow ID as the operation token
76-
// This fallback is provided for backwards compatibility for those cases.
77-
// This fallback will be removed in a future release.
78-
// See: https://github.com/temporalio/sdk-java/issues/2423
79-
return operationToken;
80-
}
69+
return loadWorkflowRunOperationToken(operationToken).getWorkflowId();
8170
}
8271

8372
/** Generate a workflow run operation token from a workflow ID and namespace. */
@@ -87,11 +76,5 @@ public static String generateWorkflowRunOperationToken(String workflowId, String
8776
return encoder.encodeToString(json.getBytes());
8877
}
8978

90-
public static class FallbackToWorkflowIdException extends RuntimeException {
91-
public FallbackToWorkflowIdException(String message) {
92-
super(message);
93-
}
94-
}
95-
9679
private OperationTokenUtil() {}
9780
}

temporal-sdk/src/test/java/io/temporal/internal/nexus/WorkflowRunTokenTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ public void deserializeWorkflowRunToken() throws IOException {
7676
}
7777

7878
@Test
79-
public void loadOldWorkflowRunToken() {
79+
public void failLoadOldWorkflowRunToken() {
8080
String operationToken = "AAAAA-BBBBB-CCCCC";
81-
Assert.assertEquals(
82-
operationToken, OperationTokenUtil.loadWorkflowIdFromOperationToken(operationToken));
81+
Assert.assertThrows(
82+
IllegalArgumentException.class,
83+
() -> OperationTokenUtil.loadWorkflowIdFromOperationToken(operationToken));
8384
}
8485

8586
@Test

0 commit comments

Comments
 (0)