Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looks like jackson's annotations are ignored #491

Open
jjant opened this issue Jul 5, 2024 · 0 comments
Open

Looks like jackson's annotations are ignored #491

jjant opened this issue Jul 5, 2024 · 0 comments
Labels
events-v4 To be pulled into aws-lambda-java-event v4

Comments

@jjant
Copy link

jjant commented Jul 5, 2024

From @botbfr, aws/aws-sdk-java#2453.

Describe the issue

I have overriden RequestHandler<I, O> with my lambda. All the jackson's annotations in my pojo (PreSignUpEvent) are ignored (Tested with JsonProperty so far). => The attributes that does not require an annotation are correctly deserialized (Because the attribute's name is the same than the object attribute's name) but not the ones with 2 different names (that's why I need to use JsonProperty annotation)

I'm using jackson v2 annotations.

I tried with RequestStreamHandler, calling in my lambda 'new ObjectMapper().readValue(InputStream, MyPojo.class)' and it worked. The annotations are taken into account.

My pojo and the lambda (just for the example here, I tried with the field 'version' -> versionn):

public class PreSignUpEvent {

    @JsonProperty("version")
    private int versionn;

    private String region;


    public PreSignUpEvent() {
    }

    public int getVersionn() {
        return versionn;
    }

    public void setVersionn(int versionn) {
        this.versionn = versionn;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }
@Named("validateUsername")
public class ValidateUsername implements RequestHandler<PreSignUpEvent, PreSignUpEvent> {

    @Override
    public PreSignUpEvent handleRequest(PreSignUpEvent input, Context context) {
 {
        LambdaLogger logger = context.getLogger();
        logger.log("input is "+input);
        return input;
}

logs:

{"region":"eu-west-1"} and version is ignored.

Do you have any idea ? Is it link to a reflection issue ?

Steps to Reproduce

Override RequestHandler<I, O> lambda,
Create a pojo that needs annotations to be deserialized

@msailes msailes added the events-v4 To be pulled into aws-lambda-java-event v4 label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events-v4 To be pulled into aws-lambda-java-event v4
Projects
None yet
Development

No branches or pull requests

2 participants