Skip to content

Commit

Permalink
Move warning log into fallback of ditto runtime exception extraction
Browse files Browse the repository at this point in the history
* This will log the warning if neither the exception nor its cause
  was a ditto runtime exception

Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed May 16, 2022
1 parent 62cbbd9 commit 00e0364
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ protected CompletionStage<Object> askTargetActor(final Object message) {
targetWithMessage.message(),
targetWithMessage.messageTimeout()
).exceptionally(throwable -> {
if (throwable instanceof AskTimeoutException askTimeoutException && targetWithMessage.internalErrorOnMessageTimeout()) {
if (throwable instanceof AskTimeoutException askTimeoutException &&
targetWithMessage.internalErrorOnMessageTimeout()) {
throw DittoRuntimeException.asDittoRuntimeException(askTimeoutException, cause ->
DittoInternalErrorException.newBuilder()
.cause(cause)
Expand Down Expand Up @@ -461,18 +462,16 @@ private void enforceAndForwardToTargetActor(final Object message) {
enforceSignalAndForwardToTargetActor((S) signal)
.whenComplete((response, throwable) -> {
if (null != throwable) {
if (!(throwable instanceof DittoRuntimeException)) {
log.withCorrelationId(signal)
.warning("Encountered Throwable when interacting with enforcer or " +
"target actor, telling sender: {}", throwable);
}

final DittoRuntimeException dre =
DittoRuntimeException.asDittoRuntimeException(throwable, t ->
DittoInternalErrorException.newBuilder()
.dittoHeaders(signal.getDittoHeaders())
.cause(t)
.build());
DittoRuntimeException.asDittoRuntimeException(throwable, t -> {
log.withCorrelationId(signal)
.warning("Encountered Throwable when interacting with enforcer " +
"or target actor, telling sender: {}", throwable);
return DittoInternalErrorException.newBuilder()
.dittoHeaders(signal.getDittoHeaders())
.cause(t)
.build();
});
log.withCorrelationId(dre)
.info("Received DittoRuntimeException during enforcement or " +
"forwarding to target actor, telling sender: {}", dre);
Expand Down Expand Up @@ -629,11 +628,11 @@ public enum Control {
}

public record DistributedPubWithMessage(DistributedPub<?> pub,
Object wrappedSignalForPublication,
Signal<?> signal) {}
Object wrappedSignalForPublication,
Signal<?> signal) {}

public record TargetActorWithMessage(ActorRef targetActor,
Object message,
Object message,
Duration messageTimeout,
boolean internalErrorOnMessageTimeout) {}

Expand Down

0 comments on commit 00e0364

Please sign in to comment.