DataType nested class
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 75/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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().
- Lenguaje dominante
- Java
- Estrellas
- 322
- Forks
- 210
- Merge medio
- 15 h 16 min
- PR fusionados (30 d)
- 29
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de hyperledger/fabric-chaincode-java
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
hyperledger/fabric-chaincode-java#628 ·
Los mantenedores suelen responder en 1 día
-
Optimize ClassGraph ScanningAbiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
hyperledger/fabric-chaincode-java#627 ·
Los mantenedores suelen responder en 1 día
-
External Chaincode Mutual TLSAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
hyperledger/fabric-chaincode-java#625 ·
Los mantenedores suelen responder en 1 día
-
Read/write batchingQuizá libre de nuevo @jadebluestar la tomó hace 118 días y no hay ningún pull request abierto. Abiertoenhancement help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
hyperledger/fabric-chaincode-java#378 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Publish docs on pushAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
hyperledger/fabric-chaincode-java#372 ·
Los mantenedores suelen responder en 1 día
Todos los issues de hyperledger/fabric-chaincode-java
Issues similares
-
status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
JabRef/jabref#17546 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
hiero-ledger/hiero-sdk-java#3010 ·
Los mantenedores suelen responder en 1 día
-
Optimize consumer version heatmap aggregation to avoid repeated scansPosiblemente ocupada @praykaria31 la tomó hoy. Abiertotype/enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Apicurio/apicurio-registry#10662 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
a:false-positive
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
status: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
spring-projects/spring-boot#52347 ·
Los mantenedores suelen responder en 2 días