GH-578 Fix FunctionRegistration lookup
The root of the issue was in implementation of equals() and hashCode() of FunctionInvocationWrapper Resolves #578
This commit is contained in:
@@ -20,7 +20,6 @@ import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.cloud.function.context.FunctionRegistration;
|
||||
import org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry.FunctionInvocationWrapper;
|
||||
import org.springframework.cloud.function.context.config.RoutingFunction;
|
||||
|
||||
/**
|
||||
@@ -33,9 +32,12 @@ public interface FunctionInspector {
|
||||
|
||||
default boolean isMessage(Object function) {
|
||||
FunctionRegistration<?> registration = getRegistration(function);
|
||||
if (registration != null && registration.getTarget() instanceof FunctionInvocationWrapper
|
||||
&& ((FunctionInvocationWrapper) registration.getTarget()).getTarget() instanceof RoutingFunction) {
|
||||
// we always want to give routing function as much information as possible
|
||||
// if (registration != null && registration.getTarget() instanceof FunctionInvocationWrapper
|
||||
// && ((FunctionInvocationWrapper) registration.getTarget()).getTarget() instanceof RoutingFunction) {
|
||||
// // we always want to give routing function as much information as possible
|
||||
// return true;
|
||||
// }
|
||||
if (registration != null && registration.getTarget() instanceof RoutingFunction) {
|
||||
return true;
|
||||
}
|
||||
return registration == null ? false : registration.getType().isMessage();
|
||||
|
||||
@@ -427,6 +427,16 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
|
||||
this.headersField.setAccessible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.target.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this.target.equals(o);
|
||||
}
|
||||
|
||||
public String getFunctionDefinition() {
|
||||
return this.functionDefinition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user