|
1 | 1 | /*
|
2 |
| - * Copyright 2020-2022 the original author or authors. |
| 2 | + * Copyright 2020-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
27 | 27 | * If registered as bean it will be autowired into {@link FunctionInvocationWrapper}.
|
28 | 28 | * Keep in mind that it only affects imperative invocations where input is {@link Message}
|
29 | 29 | *
|
30 |
| - * NOTE: This API is experimental and could change without notice. It is |
| 30 | + * NOTE: This API is experimental and and could change without notice. It is |
31 | 31 | * intended for internal use only (e.g., spring-cloud-sleuth)
|
32 | 32 | *
|
33 | 33 | * @author Oleg Zhurakousky
|
34 |
| - * @author Artem Bilan |
35 | 34 | * @since 3.1
|
36 | 35 | */
|
37 | 36 | public abstract class FunctionAroundWrapper implements BiFunction<Object, FunctionInvocationWrapper, Object> {
|
38 | 37 |
|
39 | 38 | @Override
|
40 | 39 | public final Object apply(Object input, FunctionInvocationWrapper targetFunction) {
|
41 | 40 | String functionalTracingEnabledStr = System.getProperty("spring.sleuth.function.enabled");
|
42 |
| - boolean functionalTracingEnabled = |
43 |
| - !StringUtils.hasText(functionalTracingEnabledStr) || Boolean.parseBoolean(functionalTracingEnabledStr); |
| 41 | + boolean functionalTracingEnabled = StringUtils.hasText(functionalTracingEnabledStr) |
| 42 | + ? Boolean.parseBoolean(functionalTracingEnabledStr) : true; |
44 | 43 | if (functionalTracingEnabled) {
|
45 |
| - return this.doApply(input, targetFunction); |
| 44 | + boolean isSkipOutputConversion = targetFunction.isSkipOutputConversion(); |
| 45 | + targetFunction.setSkipOutputConversion(true); |
| 46 | + try { |
| 47 | + return this.doApply(input, targetFunction); |
| 48 | + } |
| 49 | + finally { |
| 50 | + targetFunction.setSkipOutputConversion(isSkipOutputConversion); |
| 51 | + } |
46 | 52 | }
|
47 | 53 | else {
|
48 | 54 | return targetFunction.apply(input);
|
49 | 55 | }
|
50 | 56 | }
|
51 | 57 |
|
52 | 58 | protected abstract Object doApply(Object input, FunctionInvocationWrapper targetFunction);
|
53 |
| - |
54 | 59 | }
|
0 commit comments