GH-SCST-2235 Fix Partitioning issue with FunctionAroundWrapper"

This commit is contained in:
Oleg Zhurakousky
2021-10-19 17:02:03 +02:00
parent 928f652b8f
commit f7112d1ef5
4 changed files with 21 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
package org.springframework.cloud.function.grpc;
public class GrpcClientTemplate {
}

View File

@@ -37,13 +37,20 @@ public abstract class FunctionAroundWrapper implements BiFunction<Object, Functi
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public final Object apply(Object input, FunctionInvocationWrapper targetFunction) { public final Object apply(Object input, FunctionInvocationWrapper targetFunction) {
boolean isSkipOutputConversion = targetFunction.isSkipOutputConversion();
targetFunction.setSkipOutputConversion(true);
Object result = null;
if (input instanceof Message) { if (input instanceof Message) {
return this.doApply((Message<byte[]>) input, targetFunction); result = this.doApply((Message<byte[]>) input, targetFunction);
} }
else if (targetFunction.isSupplier() && !targetFunction.isOutputTypePublisher()) { else if (targetFunction.isSupplier() && !targetFunction.isOutputTypePublisher()) {
return this.doApply(null, targetFunction); result = this.doApply(null, targetFunction);
} }
return targetFunction.apply(input); else {
result = targetFunction.apply(input);
}
targetFunction.setSkipOutputConversion(isSkipOutputConversion);
return result;
} }
protected abstract Object doApply(Message<byte[]> input, FunctionInvocationWrapper targetFunction); protected abstract Object doApply(Message<byte[]> input, FunctionInvocationWrapper targetFunction);

View File

@@ -390,6 +390,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
private Function<Object, Object> enhancer; private Function<Object, Object> enhancer;
FunctionInvocationWrapper(FunctionInvocationWrapper function) { FunctionInvocationWrapper(FunctionInvocationWrapper function) {
this.expectedOutputContentType = function.expectedOutputContentType;
this.skipOutputConversion = function.skipOutputConversion; this.skipOutputConversion = function.skipOutputConversion;
this.skipInputConversion = function.skipInputConversion; this.skipInputConversion = function.skipInputConversion;
this.target = function.target; this.target = function.target;
@@ -407,6 +408,11 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
this.message = this.inputType != null && FunctionTypeUtils.isMessage(this.inputType); this.message = this.inputType != null && FunctionTypeUtils.isMessage(this.inputType);
} }
public boolean isSkipOutputConversion() {
return skipOutputConversion;
}
public boolean isPrototype() { public boolean isPrototype() {
return this.isPrototype(); return this.isPrototype();
} }

View File

@@ -66,7 +66,6 @@
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-deploy-plugin</artifactId> <artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration> <configuration>
<skip>true</skip> <skip>true</skip>
</configuration> </configuration>