DataType nested class
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 75/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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().
- Lingua principale
- Java
- Stelle
- 322
- Fork
- 210
- Merge medio
- 15h 16m
- PR unite (30g)
- 29
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hyperledger/fabric-chaincode-java
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
hyperledger/fabric-chaincode-java#628 ·
I maintainer di solito rispondono entro 1 giorno
-
Optimize ClassGraph ScanningApertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
hyperledger/fabric-chaincode-java#627 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
hyperledger/fabric-chaincode-java#625 ·
I maintainer di solito rispondono entro 1 giorno
-
Read/write batchingForse di nuovo libera @jadebluestar l’ha presa 117 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
hyperledger/fabric-chaincode-java#378 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Publish docs on pushAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
hyperledger/fabric-chaincode-java#372 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hyperledger/fabric-chaincode-java
Issue simili
-
enhancement feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
rsp777/service-pulse-app#28 ·
-
human-required sync-failed
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Azure/osdu-spi-file#63 ·
I maintainer di solito rispondono entro 1 giorno
-
area/ysql kind/enhancement priority/medium status/awaiting-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
yugabyte/yugabyte-db#35578 ·
I maintainer di solito rispondono entro 1 giorno
-
frontend quick win
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
CodeForPhilly/benefit-decision-toolkit#571 ·
I maintainer di solito rispondono entro 1 giorno
-
approved
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
checkstyle/checkstyle#22129 ·
I maintainer di solito rispondono entro 1 giorno