DataType nested class
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with TypeRegistryImpl.addDataType, TypeSchema.typeConvert/updateSchemaForClass, and JSONTransactionSerializer.createComponentInstance to trace how nested class names are registered and resolved. Reproduce the issue with the provided Outer.Inner contract and verify that schema generation and deserialization use the same reference key, with no missing registry definition.
由索引模型根据 Issue 内容生成。
描述
Description
The Java contract API appears to use inconsistent names for nested @DataType classes when creating schema references and registering types.
TypeRegistryImpl.addDataType(Class<?>) registers a data type using DataTypeDefinitionImpl.getSimpleName(). For a nested class such as Outer.Inner, Class.getSimpleName() returns Inner, so the registry key is Inner.
However, TypeSchema.typeConvert(Class<?>) uses Class.getTypeName() and passes that name to updateSchemaForClass(...). For Outer.Inner, the class name contains Outer$Inner. In TypeSchema.updateSchemaForClass(...), this line:
schema.put("$ref", "#/components/schemas/" + className.substring(className.lastIndexOf('.') + 1));
produces:
#/components/schemas/Outer$Inner
instead of:
#/components/schemas/Inner
This creates a registry lookup mismatch. During deserialization, the schema reference resolves to Outer$Inner, but the type registry contains the data type under Inner. The lookup returns null, and JSONTransactionSerializer.createComponentInstance(...) then throws a NullPointerException when it tries to use the missing definition.
The reference mismatch can also be observed directly by calling TypeSchema.typeConvert(Outer.Inner.class) from a smart contract: its "$ref" is #/components/schemas/Outer$Inner, while the registry uses the key Inner.
Steps to reproduce
-
Define a nested
@DataTypeclass:public class Outer { @DataType public static class Inner { @Property private String value; public Inner() { } } } -
Define a contract transaction that accepts the nested data type:
@Contract(name = "NestedTypeContract") public class NestedTypeContract implements ContractInterface { @Transaction public Outer.Inner echo(final Context context, final Outer.Inner input) { return input; } @Transaction public String inspectSchema(final Context context) { return TypeSchema.typeConvert(Outer.Inner.class).getRef(); } } -
Start the contract so the shim scans the
@DataTypeclass. The type registry registersOuter.Innerunder its simple name:Inner -
Invoke
inspectSchema. Observe thatTypeSchema.typeConvert(Outer.Inner.class).getRef()returns:#/components/schemas/Outer$InnerThis differs from the registry key,
Inner. -
Submit the
echotransaction with a JSON argument representingOuter.Inner:{"value":"test"} -
Observe that deserialization attempts to look up
Outer$Innerin the type registry, getsnull, and fails with aNullPointerExceptioninJSONTransactionSerializer.createComponentInstance().
- 主要语言
- Java
- 星标
- 322
- 派生
- 210
- 平均合并
- 15 小时 16 分钟
- 30 天内合并 PR
- 29
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hyperledger/fabric-chaincode-java 的其他 Issue
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
hyperledger/fabric-chaincode-java#628 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
hyperledger/fabric-chaincode-java#627 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 68/100
hyperledger/fabric-chaincode-java#625 ·
维护者通常 1 天内回复
-
Read/write batching可能重新可做 @jadebluestar 于 118 天前认领,目前没有进行中的 PR。 未关闭enhancement help wanted
难度 4/5 3-5 天 新手友好度 45/100
hyperledger/fabric-chaincode-java#378 · 4 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 52/100
hyperledger/fabric-chaincode-java#372 ·
维护者通常 1 天内回复
查看 hyperledger/fabric-chaincode-java 的全部 Issue
相似的 Issue
-
Optimize consumer version heatmap aggregation to avoid repeated scans可能已有人在做 @praykaria31 今天认领。 未关闭type/enhancement
难度 2/5 1-3 小时 新手友好度 72/100
Apicurio/apicurio-registry#10662 · 1 条评论 ·
维护者通常 1 天内回复
-
a:false-positive
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 74/100
spring-projects/spring-boot#52347 ·
维护者通常 2 天内回复
-
bug untriaged
难度 2/5 1-3 小时 新手友好度 76/100
opensearch-project/opensearch-migrations#3480 ·
维护者通常 2 天内回复
-
enhancement feature
难度 2/5 1-3 小时 新手友好度 70/100
rsp777/service-pulse-app#28 ·