aws / aws/aws-lambda-java-libs

Looks like jackson's annotations are ignored

未关闭
#491 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
events-v4
主要语言
Java
星标
548
派生
241
平均合并
2 天 5 分钟
30 天内合并 PR
11

描述

From @botbfr, https://github.com/aws/aws-sdk-java/issues/2453.

## Describe the issue
I have overriden RequestHandler 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):
```java
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 {

@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` lambda,
Create a pojo that needs annotations to be deserialized

贡献指南

打开贡献指南

调研方向

首先,使用提供的 PreSignUpEvent 重现 RequestHandler 路径,并将其与可正常工作的 RequestStreamHandler 和 ObjectMapper 示例进行比较。跟踪 RequestHandler 输入的反序列化过程;当不同名称的字段能够遵循 Jackson 注解(例如 @JsonProperty),同时现有的同名字段仍能正确反序列化时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, java
领域
api, backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。