Skip to content

Commit 76388ee

Browse files
Changes to logging:
* Suppress `kotlinx.coroutines.JobCancellationException` when irrelevant * Make sure we don't log twice for TerminalException, and reduce log level to info in that case
1 parent ad68e01 commit 76388ee

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sdk-core/src/main/java/dev/restate/sdk/core/RequestProcessorImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import dev.restate.common.Slice;
1212
import dev.restate.sdk.common.TerminalException;
13+
import dev.restate.sdk.core.statemachine.InvocationState;
1314
import dev.restate.sdk.core.statemachine.StateMachine;
1415
import dev.restate.sdk.endpoint.definition.HandlerDefinition;
1516
import io.opentelemetry.context.Context;
@@ -174,19 +175,19 @@ private CompletableFuture<Void> end(
174175
HandlerContextInternal contextInternal, @Nullable Throwable exception) {
175176
if (exception == null || ExceptionUtils.containsSuspendedException(exception)) {
176177
contextInternal.close();
177-
} else {
178-
LOG.warn("Error when processing the invocation", exception);
178+
} else if (contextInternal.getInvocationState() != InvocationState.CLOSED) {
179179
if (ExceptionUtils.isTerminalException(exception)) {
180+
LOG.info("Invocation completed with terminal error", exception);
180181
return contextInternal
181182
.writeOutput((TerminalException) exception)
182-
.thenAccept(
183-
v -> {
184-
LOG.trace("Closed correctly with non ok exception", exception);
185-
contextInternal.close();
186-
});
183+
.thenAccept(v -> contextInternal.close());
187184
} else {
185+
// No need to log here, fail inside will log
188186
contextInternal.fail(exception);
189187
}
188+
} else if (!"kotlinx.coroutines.JobCancellationException"
189+
.equals(exception.getClass().getCanonicalName())) {
190+
LOG.warn("Suppressed error after the invocation was closed:", exception);
190191
}
191192
return CompletableFuture.completedFuture(null);
192193
}

0 commit comments

Comments
 (0)