From 1b091f7772e726bc83d8eba281ea30b14f4a54a6 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 28 Jul 2021 12:39:42 +0200 Subject: [PATCH] Fix previous commit --- .../messaging/TraceFunctionAroundWrapper.java | 18 ++++++++---------- .../TraceFunctionAroundWrapperTests.java | 8 +++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapper.java b/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapper.java index b31cc3ad7..b2a0cbdc7 100644 --- a/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapper.java +++ b/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapper.java @@ -87,20 +87,18 @@ public class TraceFunctionAroundWrapper extends FunctionAroundWrapper protected Object doApply(Message message, SimpleFunctionRegistry.FunctionInvocationWrapper targetFunction) { /* - * This code is temporary to disable conditions for which this interceptor is not ready. - * For example, - * - it does not handle properly input or output of type Publisher - * - it wraps output in Message when function returns a Collection which it should not do. + * This code is temporary to disable conditions for which this interceptor is not + * ready. For example, - it does not handle properly input or output of type + * Publisher - it wraps output in Message when function returns a + * Collection which it should not do. * */ - if ( (!FunctionTypeUtils.isCollectionOfMessage(targetFunction.getOutputType()) && !targetFunction.isOutputTypePublisher()) - || (targetFunction.isSupplier() && !targetFunction.isOutputTypePublisher()) - ) { - return targetFunction.apply(message); // no instrumentation + if ((FunctionTypeUtils.isCollectionOfMessage(targetFunction.getOutputType()) + || targetFunction.isOutputTypePublisher()) + || (targetFunction.isSupplier() && targetFunction.isOutputTypePublisher())) { + return targetFunction.apply(message); // no instrumentation } - - MessageAndSpans invocationMessage = null; Span span; if (message == null && targetFunction.isSupplier()) { // Supplier diff --git a/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapperTests.java b/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapperTests.java index 96da71089..df29fcc70 100644 --- a/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapperTests.java +++ b/tests/common/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceFunctionAroundWrapperTests.java @@ -74,9 +74,11 @@ public abstract class TraceFunctionAroundWrapperTests { function.setSkipOutputConversion(true); Object result = function.get(); assertThat(result).isInstanceOf(Publisher.class); - /* TODO - * We'll need more assertions but for now this one will ensure that wrapper does not change the type of return value - * specifically for reactive cases where Flux became Message due to the current code in TraceFunctionAroundWrapper + /* + * TODO We'll need more assertions but for now this one will ensure that + * wrapper does not change the type of return value specifically for reactive + * cases where Flux became Message due to the current code in + * TraceFunctionAroundWrapper */ } }