Skip to content

Commit

Permalink
Log a warning if calling the new endpoint fails in a reactive flow
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvisser committed Oct 2, 2023
1 parent 57b373a commit c13090d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/io/github/rabobank/shadow_tool/ShadowFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ShadowFlow<T> {
private static final String INSTANCE_PREFIX_FORMAT = "[instance=%s]";
private static final String DEFAULT_INSTANCE_NAME = "default";
private static final String CALLING_NEW_FLOW = "{} Calling new flow: {}";
private static final String FAILED_TO_COMPARE = "{} Failed to run the shadow flow";
private static final String DEFAULT_ALGORITHM = "RSA";
private static final String DEFAULT_ALGORITHM_MODE_PADDING =
DEFAULT_ALGORITHM + "/ECB/OAEPWITHSHA-256ANDMGF1PADDING";
Expand Down Expand Up @@ -134,6 +135,7 @@ public Mono<T> compare(final Mono<T> currentFlow, final Mono<T> newFlow) {
logger.info(CALLING_NEW_FLOW, instanceNameLogPrefix, callNewFlow);
if (callNewFlow) {
newFlow.doOnNext(newResponse -> logDifferences(javers.compare(currentResponse, newResponse)))
.doOnError(ex -> logger.warn(FAILED_TO_COMPARE, instanceNameLogPrefix, ex))
.contextWrite(contextView)
.subscribeOn(scheduler)
.subscribe();
Expand Down Expand Up @@ -164,6 +166,7 @@ public Mono<Collection<T>> compareCollections(final Mono<? extends Collection<T>
logger.info(CALLING_NEW_FLOW, instanceNameLogPrefix, callNewFlow);
if (callNewFlow) {
newFlow.doOnNext(newResponse -> logDifferences(javers.compareCollections(currentResponse, newResponse, clazz)))
.doOnError(ex -> logger.warn(FAILED_TO_COMPARE, instanceNameLogPrefix, ex))
.contextWrite(contextView)
.subscribeOn(scheduler)
.subscribe();
Expand All @@ -180,7 +183,7 @@ private void doShadowFlow(final Supplier<Diff> diffSupplier) {
try {
executorService.submit(() -> logDifferenceWithMdc(diffSupplier, contextMap));
} catch (final Exception e) {
logger.error("{} Failed to run the shadow flow", instanceNameLogPrefix, e);
logger.warn(FAILED_TO_COMPARE, instanceNameLogPrefix, e);
}
}
}
Expand All @@ -190,7 +193,7 @@ private void logDifferenceWithMdc(final Supplier<Diff> diffSupplier, final Map<S
try {
logDifferences(diffSupplier.get());
} catch (final Exception e) {
logger.error("{} Failed to run the shadow flow", instanceNameLogPrefix, e);
logger.warn(FAILED_TO_COMPARE, instanceNameLogPrefix, e);
} finally {
MDC.clear();
}
Expand Down

0 comments on commit c13090d

Please sign in to comment.