Repository: quarkusio/quarkus
Issue: NPE in LambdaHttpHandler (amazon-lambda-http extension)

### Describe the bug

While testing a Quarkus Lambda function, I hit the following NPE:

ERROR [qua.ama.lam.http] (main) Request Failure: java.lang.NullPointerException
at io.quarkus.amazon.lambda.http.LambdaHttpHandler.nettyDispatch(LambdaHttpHandler.java:171)
at io.quarkus.amazon.lambda.http.LambdaHttpHandler.handleRequest(LambdaHttpHandler.java:63)
at io.quarkus.amazon.lambda.http.LambdaHttpHandler.handleRequest(LambdaHttpHandler.java:43)
at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.handle(AmazonLambdaRecorder.java:71)
at io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler.handleRequest(QuarkusStreamHandler.java:58)
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 lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:257)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:192)
at lambdainternal.AWSLambda.main(AWSLambda.java:187)

Would be nicer to get a proper error message. I'm willing to open a PR, just wondering what would be the best way to fix/ validate this?

@patriot1burke @richiethom @HardNorth 

### Expected behavior

A proper error message

### Actual behavior

NullPointerException

### How to Reproduce?

1. Open a deployed Quarkus Lambda function in AWS console
2. Hit Test button
3. NPE is shown in Log output section

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

Java 11 (Corretto)

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.1.0

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Maven 3.8.1

### Additional information

_No response_

Changed files:
extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java

diff --git a/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java b/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java
index 7236fe332fe..dea92dbf76d 100644
--- a/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java
+++ b/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java
@@ -167,8 +167,16 @@ private APIGatewayV2HTTPResponse nettyDispatch(InetSocketAddress clientAddress,
         quarkusHeaders.setContextObject(Context.class, context);
         quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.class, request);
         quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.RequestContext.class, request.getRequestContext());
+        HttpMethod httpMethod = null;
+        if (request.getRequestContext() != null && request.getRequestContext().getHttp() != null
+                && request.getRequestContext().getHttp().getMethod() != null) {
+            httpMethod = HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod());
+        }
+        if (httpMethod == null) {
+            throw new IllegalStateException("Missing HTTP method in request event");
+        }
         DefaultHttpRequest nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
-                HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod()), ofNullable(request.getRawQueryString())
+                httpMethod, ofNullable(request.getRawQueryString())
                         .filter(q -> !q.isEmpty()).map(q -> request.getRawPath() + '?' + q).orElse(request.getRawPath()),
                 quarkusHeaders);
         if (request.getHeaders() != null) { //apparently this can be null if no headers are sent