micronaut-projects / micronaut-aws

Projects specific to integrating Micronaut and Amazon Web Services (AWS)
Apache License 2.0
87 stars 80 forks source link

GraalVM and Amazon API Gateway fail with 1.9 version of aws-serverless-java-container #1550

Closed sdelamo closed 1 year ago

sdelamo commented 1 year ago

Expected Behavior

Since version 1.9 aws-serverless-java-container introduced SingleValueHeaders.java.

It should work fine with a FAT JAR or native executable.

Actual Behaviour

With Java it works fine. but with native execuiable it fails:

Fails with:

Caused by: io.micronaut.http.codec.CodecException: Error decoding stream for type [class com.amazonaws.serverless.proxy.model.AwsProxyRequest]: Cannot construct instance of `com.amazonaws.serverless.proxy.model.SingleValueHeaders` (no Creators, like default constructor, exist): no default constructor found
at [Source: (byte[])"{"resource":"/","path":"/","httpMethod":"GET","headers":{"Accept":"*/*","CloudFront-Forwarded-Proto":"https","CloudFront-Is-Desktop-Viewer":"true","CloudFront-Is-Mobile-Viewer":"false","CloudFront-Is-SmartTV-Viewer":"false","CloudFront-Is-Tablet-Viewer":"false","CloudFront-Viewer-ASN":"3352","CloudFront-Viewer-Country":"ES","Host":"644w7xh6r1.execute-api.us-east-1.amazonaws.com","User-Agent":"curl/7.84.0","Via":"2.0 d965728bf3120b9df2983219ebe95680.cloudfront.net (CloudFront)","X-Amz-Cf-Id":"Enl"[truncated 1804 bytes]; line: 1, column: 57] (through reference chain: com.amazonaws.serverless.proxy.model.AwsProxyRequest["headers"])

SingleValueHeader looks like:

package com.amazonaws.serverless.proxy.model;

import java.util.TreeMap;

public class SingleValueHeaders extends TreeMap<String, String> {

    private static final long serialVersionUID = 42L;

    public SingleValueHeaders() {
        super(String.CASE_INSENSITIVE_ORDER);
    }
}

Steps To Reproduce

Environment Information

x86 architecture

Example Application

Sample App

Version

3.8.0-SNAPSHOT

sdelamo commented 1 year ago

Adding @TypeHint for SingleValueHeaders did not work.

however, adding both @TypeHint for SingleValueHeaders and @TreeMap did work. Thanks @n0tl3ss !