aws / aws/aws-lambda-java-libs
Bug: JSON serialization ignores fields from child classes (Java 8 Lambda runtime works, Java 11 Lambda runtime fails)
- 主要语言
- Java
- 星标
- 548
- 派生
- 241
- 平均合并
- 2 天 5 分钟
- 30 天内合并 PR
- 11
描述
I noticed this issue when updating my lambda function from Java 8 to Java 11, and it seems to be related to the code in this repository.
The problematic situation occurs when a lambda function declares that it returns `TestParent`, but actually returns an instance of `TestChild`:
```java
public class TestParent {
public String parentField = "parentField";
}
public class TestChild extends TestParent {
public String childField = "childField";
}
```
To reproduce the issue, please run the attached test case (maven project): [aws-lambda-json-child-field-bug.zip](https://github.com/aws/aws-lambda-java-libs/files/9210528/aws-lambda-json-child-field-bug.zip)
It should fail with an error like below:
```
org.junit.ComparisonFailure:
Expected :{"parentField":"parentField","childField":"childField"}
Actual :{"parentField":"parentField"}
```
You can see that the fields from `TestChild` are missing. This is the issue, and this seems to be new -- in the Java 8 lambda runtime this worked ok.
Thanks for any help!
贡献指南
调研方向
首先,在 Java 11 Lambda 运行时上运行随附的 aws-lambda-json-child-field-bug.zip Maven 测试用例,并将其与 Java 8 进行比较。跟踪测试所使用的 JSON 序列化入口点;当序列化后的 TestChild 实例同时包含 parentField 和 childField 时即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- aws, java
- 领域
- cloud
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100