use of io.temporal.internal.replay.FailureWrapperException in project sdk-java by temporalio.
the class POJOActivityTaskHandler method mapToActivityFailure.
@SuppressWarnings("deprecation")
private ActivityTaskHandler.Result mapToActivityFailure(Throwable exception, String activityId, Scope metricsScope, boolean isLocalActivity) {
if (exception instanceof ActivityCanceledException) {
if (isLocalActivity) {
metricsScope.counter(MetricsType.LOCAL_ACTIVITY_EXEC_CANCELLED_COUNTER).inc(1);
metricsScope.counter(MetricsType.LOCAL_ACTIVITY_CANCELED_COUNTER).inc(1);
} else {
metricsScope.counter(MetricsType.ACTIVITY_EXEC_CANCELLED_COUNTER).inc(1);
metricsScope.counter(MetricsType.ACTIVITY_CANCELED_COUNTER).inc(1);
}
String stackTrace = FailureConverter.serializeStackTrace(exception);
throw new FailureWrapperException(Failure.newBuilder().setStackTrace(stackTrace).setCanceledFailureInfo(CanceledFailureInfo.newBuilder()).build());
}
Scope ms = metricsScope.tagged(ImmutableMap.of(MetricsTag.EXCEPTION, exception.getClass().getSimpleName()));
if (isLocalActivity) {
ms.counter(MetricsType.LOCAL_ACTIVITY_EXEC_FAILED_COUNTER).inc(1);
ms.counter(MetricsType.LOCAL_ACTIVITY_FAILED_COUNTER).inc(1);
} else {
ms.counter(MetricsType.ACTIVITY_EXEC_FAILED_COUNTER).inc(1);
}
if (exception instanceof TemporalFailure) {
((TemporalFailure) exception).setDataConverter(dataConverter);
}
if (exception instanceof TimeoutFailure) {
exception = new SimulatedTimeoutFailure((TimeoutFailure) exception);
}
Failure failure = FailureConverter.exceptionToFailure(exception);
RespondActivityTaskFailedRequest.Builder result = RespondActivityTaskFailedRequest.newBuilder().setFailure(failure);
return new ActivityTaskHandler.Result(activityId, null, new Result.TaskFailedResult(result.build(), exception), null, null, false);
}
Aggregations