Skip to content

Commit 2d473e7

Browse files
committed
Ensure RoutingFuunction can't route to itself
1 parent eec09ca commit 2d473e7

File tree

1 file changed

+6
-0
lines changed
  • spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config

1 file changed

+6
-0
lines changed

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/RoutingFunction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ else if (StringUtils.hasText(functionProperties.getRoutingExpression())) {
193193
}
194194
}
195195

196+
if (function.getTarget().equals(this)) {
197+
throw new IllegalStateException("Failed to establish route, and routing to itself is not allowed as it creates a loop. Please provide: "
198+
+ "'spring.cloud.function.definition' as Message header or as application property or "
199+
+ "'spring.cloud.function.routing-expression' as application property.");
200+
}
201+
196202
return function.apply(input);
197203
}
198204

0 commit comments

Comments
 (0)