Closed Morras closed 3 years ago
Yes, I agree with you. I think the only reason it's there, is because if the clazz.getConstructor().newInstance(), throws an Exception, the handleInvocationException(..) method needs to be called.
I'll take a look and see if I can reorganize things.
Fixed in Release 2.2.2
Each invocation of the LambdaFunction calls the constructor of the provided Lambda handler.
This goes against the normal behaviour of the Java runtime, which only instantiates the Lambda handler class on the first invocation. The [custom runtime documentation](Initialization tasks) also mentions that "Initialize the function" should happen in the Initialization step and not when processing tasks.
Looking at the code, I think it is a matter of moving line 207 of LambdaRuntime outside the
while(true)
loop, but don't have enough context to be sure that does not break anything else.I might find some time to experiment with this next week.