spring-integration
spring-integration copied to clipboard
Revise LambdaMessageProcessor to call well-known lambdas directly, not via reflection
Right now it does ReflectionUtils.makeAccessible(this.method); and then Object result = this.method.invoke(this.target, args);, but probably we can call Function.apply(), GenericHandler.handle(), GenericSelector.accept(), etc. directly since we know the places LambdaMessageProcessor is used, plus we can infer the type of the lambda and delegate to respective strategy.
NOTE: With Java 17 we have to add --add-opens java.base/java.util.function=ALL-UNNAMED when Function lambda is in use.
Not having method.setAccessible(true) in this case does not help: it still fail on method.invoke() because cannot get access to the method even if it is public by definition of lambda itself.