spring-integration icon indicating copy to clipboard operation
spring-integration copied to clipboard

Revise LambdaMessageProcessor to call well-known lambdas directly, not via reflection

Open artembilan opened this issue 4 years ago • 0 comments

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.

artembilan avatar Nov 03 '21 18:11 artembilan