Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ private void convertKnownFailures(Throwable e) {
}
throw new HandlerException(HandlerException.ErrorType.BAD_REQUEST, failure);
}
if (failure instanceof IllegalArgumentException) {
throw new HandlerException(HandlerException.ErrorType.BAD_REQUEST, failure);
}
if (failure instanceof ApplicationFailure) {
if (((ApplicationFailure) failure).isNonRetryable()) {
throw new HandlerException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,34 @@ public void startTaskWithUndeserializableInput() throws TimeoutException {
Assert.assertFalse(e.isRetryable());
}

@Test
public void startTaskHandlerMissingBothActivityTimeoutOptions() throws TimeoutException {
WorkflowClient client = mock(WorkflowClient.class);
NexusTaskHandlerImpl nexusTaskHandlerImpl =
new NexusTaskHandlerImpl(
client, NAMESPACE, TASK_QUEUE, dataConverter, new WorkerInterceptor[] {});
nexusTaskHandlerImpl.registerNexusServiceImplementations(
new Object[] {new ThrowingIllegalArgumentServiceImpl()});
nexusTaskHandlerImpl.start();

PollNexusTaskQueueResponse.Builder task =
PollNexusTaskQueueResponse.newBuilder()
.setRequest(
Request.newBuilder()
.setStartOperation(
StartOperationRequest.newBuilder()
.setOperation("operation")
.setService("TestNexusService1")
.setPayload(dataConverter.toPayload("input").get())
.build()));

NexusTaskHandler.Result result =
nexusTaskHandlerImpl.handle(new NexusTask(task, null, null), metricsScope);
HandlerException e = result.getHandlerException();
Assert.assertNotNull(e);
Assert.assertEquals(HandlerException.ErrorType.BAD_REQUEST, e.getErrorType());
}

@Test
public void startAsyncSyncOperation() throws TimeoutException {
WorkflowClient client = mock(WorkflowClient.class);
Expand Down Expand Up @@ -405,6 +433,18 @@ public OperationHandler<String, String> operation() {
}
}

@ServiceImpl(service = TestNexusServices.TestNexusService1.class)
public class ThrowingIllegalArgumentServiceImpl {
@OperationImpl
public OperationHandler<String, String> operation() {
return OperationHandler.sync(
(ctx, details, input) -> {
throw new IllegalArgumentException(
"at least one of StartToCloseTimeout or ScheduleToCloseTimeout is required");
});
}
}

@ServiceImpl(service = TestNexusServices.TestNexusService1.class)
public class TestNexusServiceImpl {
@OperationImpl
Expand Down
Loading