aws / aws/aws-lambda-java-libs

Looks like jackson's annotations are ignored

Đang mở
#491 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
events-v4
Ngôn ngữ chính
Java
Star
548
Fork
241
Merge trung bình
2 ngày 5 phút
Pull request đã merge (30 ngày)
11

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.