Repository: localstack/localstack

Issue:
bug: java.lang.IllegalArgumentException: argument type mismatch with RequestHandler
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

The following request handler:

```java
public class LegalDocPublisher implements RequestHandler<SQSEvent, Void> {
    @Override
    public Void handleRequest(final SQSEvent event, final Context context) {
        return null;
    }
}
```

causes 

```
2022-10-10T06:38:23.362  INFO --- [  Thread-244] l.s.a.lambda_executors     : Error executing Lambda "arn:aws:lambda:us-east-2:000000000000:function:LegalDocPublisher": InvocationException: Lambda process returned error status code: 1. Result: . Output:
Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at cloud.localstack.LambdaExecutor.main(LambdaExecutor.java:117)   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 1423, in do_execute
    execute_result = lambda_function_callable(inv_context.event, context)
  File "/opt/code/localstack/localstack/services/awslambda/lambda_api.py", line 579, in execute
    result = lambda_executors.EXECUTOR_LOCAL.execute_java_lambda(
  File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 1532, in execute_java_lambda
    invocation_result = self._execute_in_custom_runtime(cmd, lambda_function=lambda_function)
  File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 1366, in _execute_in_custom_runtime
    raise InvocationException(
```

when execution is triggered.

This works fine until LocalStack 1.0.4.

### Expected Behavior

No exceptions.

### How are you starting LocalStack?

Custom (please describe below)

### Steps To Reproduce

LocalStack is started as part of integration tests run by Maven, via `docker-maven-plugin`.

### Environment

```markdown
- OS: 20.04
- LocalStack: 1.2.0
```


### Anything else?

AWS SDK version: 1.12.271


Discussion:
Hi!
Please use a docker lambda executor, by using `LAMBDA_EXECUTOR=docker` and mounting the docker socket into your container instead of the local executor. If you are looking for better performance, I recommend setting `PROVIDER_OVERRIDE_LAMBDA=asf`, which will change the lambda provider to our new one.
The local executor is quite error prone, including this.
Thank you @dfangl I'll try out your suggestions and let you know.
While my original suggestions still stand, I will also fix this regression in the local provider.
I would still recommend not using it wherever possible, but regressions should not happen regardless.

Resolving patch:
diff --git a/localstack/services/awslambda/packages.py b/localstack/services/awslambda/packages.py
--- a/localstack/services/awslambda/packages.py
+++ b/localstack/services/awslambda/packages.py
@@ -101,10 +101,10 @@ def _install(self, target: InstallTarget) -> None:
 
 class AWSLambdaJavaPackage(Package):
     def __init__(self):
-        super().__init__("LambdaJavaLibs", "0.2.21")
+        super().__init__("LambdaJavaLibs", "0.2.22")
 
     def get_versions(self) -> List[str]:
-        return ["0.2.21"]
+        return ["0.2.22", "0.2.21"]
 
     def _get_installer(self, version: str) -> PackageInstaller:
         return AWSLambdaJavaPackageInstaller("lambda-java-libs", version)


Test patch: