Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ to docs, or any other relevant information.
as asynchronous.
- Client request metrics (`temporal_long_request_latency` etc.) now always carry the `update_name` tag (default
`none`), fixing Prometheus tag-key conflicts when Workflow Updates are used (#3210).
- The default JSON converter omits the live cancellation token from `NexusOperationInfo`,
avoiding an extra cancellation callback each time an application serializes the info.

## [1.41.1] - 2026-11-16

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.temporal.internal.nexus;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.temporal.common.CancellationToken;
import io.temporal.nexus.NexusOperationInfo;
import java.util.concurrent.CancellationException;
Expand Down Expand Up @@ -62,6 +63,7 @@ public String getOperation() {
}

@Override
@JsonIgnore
public CancellationToken<CancellationException> getCancellationToken() {
return cancellationToken;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ default String getRequestId() {
* reason.
*
* <p>Cancellation callbacks may run on the Nexus timeout thread and must return promptly.
*
* <p>The SDK's default JSON converter omits the live token when serializing this info.
*/
CancellationToken<CancellationException> getCancellationToken();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.temporal.internal.nexus;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import io.temporal.api.common.v1.Payload;
import io.temporal.common.CancellationToken;
import io.temporal.common.converter.DataConverter;
import io.temporal.common.converter.DefaultDataConverter;
import io.temporal.internal.concurrent.structured.CancelSource;
import io.temporal.nexus.NexusOperationInfo;
import java.util.Map;
import java.util.concurrent.CancellationException;
import org.junit.Test;

public class NexusInfoImplTest {
@Test
public void serializesMetadataWithoutAccessingCancellationFuture() {
CancelSource<CancellationException> source = new CancelSource<>(CancellationException::new);
CancellationToken<CancellationException> token = spy(source.token());
NexusOperationInfo info =
new NexusInfoImpl(
"namespace", "queue", "endpoint", "service", "operation", "request-id", token);
DataConverter converter = DefaultDataConverter.STANDARD_INSTANCE;

Payload payload = converter.toPayload(info).get();
Map<?, ?> metadata = converter.fromPayload(payload, Map.class, Map.class);

verify(token, never()).getCancellationFuture();
assertFalse(metadata.containsKey("cancellationToken"));
assertEquals("namespace", metadata.get("namespace"));
assertEquals("queue", metadata.get("taskQueue"));
assertEquals("endpoint", metadata.get("endpoint"));
assertEquals("service", metadata.get("service"));
assertEquals("operation", metadata.get("operation"));
assertEquals("request-id", metadata.get("requestId"));
assertSame(token, info.getCancellationToken());
}
}
Loading