Skip to content

Commit 6f5735e

Browse files
committed
Revert "Use long poll token in describeActivity."
This reverts commit 749a8c7.
1 parent 6d54d34 commit 6f5735e

8 files changed

Lines changed: 10 additions & 104 deletions

File tree

temporal-sdk/src/main/java/io/temporal/client/ActivityExecutionDescription.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ public final class ActivityExecutionDescription extends ActivityExecutionMetadat
3030
private final ActivityExecutionInfo info;
3131
private final DataConverter dataConverter;
3232
private final String namespace;
33-
private final @Nullable byte[] longPollToken;
3433

3534
public ActivityExecutionDescription(
36-
ActivityExecutionInfo info,
37-
DataConverter dataConverter,
38-
String namespace,
39-
@Nullable byte[] longPollToken) {
35+
ActivityExecutionInfo info, DataConverter dataConverter, String namespace) {
4036
super(
4137
null,
4238
info.getActivityId(),
@@ -55,7 +51,6 @@ public ActivityExecutionDescription(
5551
this.info = info;
5652
this.dataConverter = dataConverter;
5753
this.namespace = namespace;
58-
this.longPollToken = longPollToken;
5954
}
6055

6156
private static @Nullable String nullIfEmpty(String s) {
@@ -148,15 +143,6 @@ public String getLastWorkerIdentity() {
148143
return w.isEmpty() ? null : w;
149144
}
150145

151-
/**
152-
* Token for a follow-on {@link UntypedActivityHandle#describe(byte[])} call. Pass this token to
153-
* long-poll until the activity state changes. {@code null} when the activity is complete.
154-
*/
155-
@Nullable
156-
public byte[] getLongPollToken() {
157-
return longPollToken;
158-
}
159-
160146
/** Time when the next retry attempt will be scheduled. */
161147
@Nullable
162148
public Instant getNextAttemptScheduleTime() {

temporal-sdk/src/main/java/io/temporal/client/ActivityHandleImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ public ActivityExecutionDescription describe() {
8585
return delegate.describe();
8686
}
8787

88-
@Override
89-
public ActivityExecutionDescription describe(@Nullable byte[] longPollToken) {
90-
return delegate.describe(longPollToken);
91-
}
92-
9388
@Override
9489
public void cancel() {
9590
delegate.cancel();

temporal-sdk/src/main/java/io/temporal/client/UntypedActivityHandle.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,6 @@ <R> CompletableFuture<R> getResultAsync(
9494
*/
9595
ActivityExecutionDescription describe();
9696

97-
/**
98-
* Long-polls until the activity state changes from the state encoded in {@code longPollToken},
99-
* then returns the updated description. Pass the token from a previous {@link #describe()} call
100-
* via {@link ActivityExecutionDescription#getLongPollToken()}. If {@code longPollToken} is {@code
101-
* null}, returns the current state immediately (equivalent to {@link #describe()}).
102-
*
103-
* @param longPollToken token from a previous describe response, or {@code null} for an immediate
104-
* snapshot
105-
* @return updated description of the activity
106-
*/
107-
ActivityExecutionDescription describe(@Nullable byte[] longPollToken);
108-
10997
/**
11098
* Requests cancellation of the activity. The activity will receive a cancellation via {@link
11199
* io.temporal.activity.ActivityExecutionContext#heartbeat(Object)}.

temporal-sdk/src/main/java/io/temporal/common/interceptors/ActivityClientCallsInterceptor.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,10 @@ public R getResult() {
271271
final class DescribeActivityInput {
272272
private final String id;
273273
private final @Nullable String runId;
274-
private final @Nullable byte[] longPollToken;
275274

276275
public DescribeActivityInput(String id, @Nullable String runId) {
277-
this(id, runId, null);
278-
}
279-
280-
public DescribeActivityInput(
281-
String id, @Nullable String runId, @Nullable byte[] longPollToken) {
282276
this.id = id;
283277
this.runId = runId;
284-
this.longPollToken = longPollToken;
285278
}
286279

287280
public String getId() {
@@ -292,11 +285,6 @@ public String getId() {
292285
public String getRunId() {
293286
return runId;
294287
}
295-
296-
@Nullable
297-
public byte[] getLongPollToken() {
298-
return longPollToken;
299-
}
300288
}
301289

302290
@Experimental

temporal-sdk/src/main/java/io/temporal/internal/client/ActivityHandleImpl.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,9 @@ public <R> CompletableFuture<R> getResultAsync(
113113

114114
@Override
115115
public ActivityExecutionDescription describe() {
116-
return describe(null);
117-
}
118-
119-
@Override
120-
public ActivityExecutionDescription describe(@Nullable byte[] longPollToken) {
121116
return clientCallsInterceptor
122117
.describeActivity(
123-
new ActivityClientCallsInterceptor.DescribeActivityInput(
124-
activityId, activityRunId, longPollToken))
118+
new ActivityClientCallsInterceptor.DescribeActivityInput(activityId, activityRunId))
125119
.getDescription();
126120
}
127121

temporal-sdk/src/main/java/io/temporal/internal/client/RootActivityClientInvoker.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,10 @@ public DescribeActivityOutput describeActivity(DescribeActivityInput input) {
279279
if (input.getRunId() != null) {
280280
req.setRunId(input.getRunId());
281281
}
282-
if (input.getLongPollToken() != null) {
283-
req.setLongPollToken(ByteString.copyFrom(input.getLongPollToken()));
284-
}
285282
DescribeActivityExecutionResponse response = genericClient.describeActivity(req.build());
286-
byte[] token =
287-
response.getLongPollToken().isEmpty() ? null : response.getLongPollToken().toByteArray();
288283
return new DescribeActivityOutput(
289284
new ActivityExecutionDescription(
290-
response.getInfo(),
291-
clientOptions.getDataConverter(),
292-
clientOptions.getNamespace(),
293-
token));
285+
response.getInfo(), clientOptions.getDataConverter(), clientOptions.getNamespace()));
294286
}
295287

296288
@Override

temporal-sdk/src/test/java/io/temporal/client/ActivityExecutionDescriptionTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ private ActivityExecutionInfo buildInfo(String activityId, String runId) {
3838
@Test
3939
public void testNullRunIdWhenEmpty() {
4040
ActivityExecutionDescription desc =
41-
new ActivityExecutionDescription(buildInfo("act-id", ""), CONVERTER, "test-ns", null);
41+
new ActivityExecutionDescription(buildInfo("act-id", ""), CONVERTER, "test-ns");
4242
assertNull(desc.getActivityRunId());
4343
}
4444

4545
@Test
4646
public void testScheduledTime() {
4747
ActivityExecutionDescription desc =
48-
new ActivityExecutionDescription(buildInfo("act-id", ""), CONVERTER, "test-ns", null);
48+
new ActivityExecutionDescription(buildInfo("act-id", ""), CONVERTER, "test-ns");
4949
assertEquals(Instant.ofEpochMilli(1000), desc.getScheduledTime());
5050
}
5151

5252
@Test
5353
public void testHasHeartbeatDetailsAbsent() {
5454
ActivityExecutionDescription desc =
55-
new ActivityExecutionDescription(buildInfo("id", "run"), CONVERTER, "test-ns", null);
55+
new ActivityExecutionDescription(buildInfo("id", "run"), CONVERTER, "test-ns");
5656
assertFalse(desc.hasHeartbeatDetails());
5757
assertFalse(desc.getHeartbeatDetails(String.class).isPresent());
5858
}
@@ -63,7 +63,7 @@ public void testGetHeartbeatDetailsPresent() {
6363
ActivityExecutionInfo info =
6464
buildInfo("id", "run").toBuilder().setHeartbeatDetails(encoded).build();
6565
ActivityExecutionDescription desc =
66-
new ActivityExecutionDescription(info, CONVERTER, "test-ns", null);
66+
new ActivityExecutionDescription(info, CONVERTER, "test-ns");
6767

6868
assertTrue(desc.hasHeartbeatDetails());
6969
Optional<String> result = desc.getHeartbeatDetails(String.class);
@@ -79,7 +79,7 @@ public void testGetHeartbeatDetailsWithExplicitGenericType() {
7979
ActivityExecutionInfo info =
8080
buildInfo("id", "run").toBuilder().setHeartbeatDetails(encoded).build();
8181
ActivityExecutionDescription desc =
82-
new ActivityExecutionDescription(info, CONVERTER, "test-ns", null);
82+
new ActivityExecutionDescription(info, CONVERTER, "test-ns");
8383

8484
Type genericType = new TypeToken<List<String>>() {}.getType();
8585
Class<List<String>> listClass = (Class<List<String>>) (Class<?>) List.class;
@@ -98,7 +98,7 @@ public void testGetWorkerDeploymentVersionPresent() {
9898
ActivityExecutionInfo info =
9999
buildInfo("id", "run").toBuilder().setLastDeploymentVersion(protoVersion).build();
100100
ActivityExecutionDescription desc =
101-
new ActivityExecutionDescription(info, CONVERTER, "test-ns", null);
101+
new ActivityExecutionDescription(info, CONVERTER, "test-ns");
102102

103103
WorkerDeploymentVersion version = desc.getWorkerDeploymentVersion();
104104
assertNotNull(version);
@@ -113,7 +113,7 @@ public void testGetPriorityPresent() {
113113
ActivityExecutionInfo info =
114114
buildInfo("id", "run").toBuilder().setPriority(protoPriority).build();
115115
ActivityExecutionDescription desc =
116-
new ActivityExecutionDescription(info, CONVERTER, "test-ns", null);
116+
new ActivityExecutionDescription(info, CONVERTER, "test-ns");
117117

118118
Priority priority = desc.getPriority();
119119
assertNotNull(priority);

temporal-sdk/src/test/java/io/temporal/client/functional/StandaloneActivityTest.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -410,43 +410,6 @@ public void testDescribeUserMetadataIsAccurate() {
410410
assertEquals("Test details\nLine 2", desc.getStaticDetails());
411411
}
412412

413-
@Test
414-
public void testDescribeLongPollObservesCompletion() throws Exception {
415-
assumeTrue(SDKTestWorkflowRule.useExternalService);
416-
asyncStartLatch = new CountDownLatch(1);
417-
try {
418-
ActivityClient client = newActivityClient();
419-
ActivityHandle<String> handle =
420-
client.start(
421-
AsyncCompletionActivity.class,
422-
AsyncCompletionActivity::complete,
423-
simpleOpts(uniqueId()));
424-
425-
assertTrue("Activity did not start within 30s", asyncStartLatch.await(30, TimeUnit.SECONDS));
426-
427-
ActivityExecutionDescription desc = handle.describe();
428-
assertEquals(ActivityExecutionStatus.ACTIVITY_EXECUTION_STATUS_RUNNING, desc.getStatus());
429-
assertNotNull("Running activity must have a long-poll token", desc.getLongPollToken());
430-
431-
// Long-poll in background — blocks until server detects a state change
432-
CompletableFuture<ActivityExecutionDescription> longPollFuture =
433-
CompletableFuture.supplyAsync(() -> handle.describe(desc.getLongPollToken()));
434-
435-
// Complete the activity externally so the server unblocks the poll
436-
client
437-
.newActivityCompletionClient()
438-
.completeStandalone(asyncActivityId, Optional.empty(), "long-poll-result");
439-
440-
ActivityExecutionDescription updated = longPollFuture.get(30, TimeUnit.SECONDS);
441-
assertEquals(
442-
ActivityExecutionStatus.ACTIVITY_EXECUTION_STATUS_COMPLETED, updated.getStatus());
443-
} finally {
444-
asyncStartLatch = null;
445-
asyncActivityId = null;
446-
asyncActivityRunId = null;
447-
}
448-
}
449-
450413
@Test
451414
public void testCancelRunningActivitySucceeds() throws InterruptedException {
452415
assumeTrue(SDKTestWorkflowRule.useExternalService);

0 commit comments

Comments
 (0)