Fields missing even with @Property. Unclear documentation?
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- java
- Área
- documentation
Línea de trabajo
Empieza leyendo la documentación de la anotación @Property junto con DataTypeDefinitionImpl y JSONTransactionSerializer, que el informe identifica como las rutas relevantes. Aclara que un campo anotado necesita un getter para aparecer en el JSON devuelto y actualiza la documentación de la anotación para que el comportamiento de serialización esperado del ejemplo Sale no sea ambiguo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Steps to reproduce
I'm looking at version 2.3 but I think the behavior holds for the lastest version.
The following code is based on https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-basic/chaincode-java.
@DataType
public class Sale {
@Property
private String guid = "1";
public Object getPK() {
return guid;
}
}
@Contract
public final class AssetTransfer implements ContractInterface {
@Transaction(intent = Transaction.TYPE.EVALUATE)
public Sale getSale(final Context ctx) {
return new Sale();
}
}
Run the code on the test-network.
What I expect
When I call
peer chaincode query -C mychannel -n basic -c '{"Args":["getSale"]}'
I expect to see a non-empty output. The output might be {guid:"1"} or {PK:"1"}, I don't know.
Since I already used @Property to annotate a field, I do not expect to see an empty json, i.e., {}.
What actually happened
$ peer chaincode query -C mychannel -n basic -c '{"Args":["getSale"]}'
{}
Discussion
I looked into fabric-chaincode-java. The constructor of DataTypeDefinitionImpl puts "guid" to this.properties. Then we execute JSONTransactionSerializer.toBuffer(). We will run final JSONObject obj = new JSONObject(new JSONObject(value), propNames); where propNames is ["guid"]. JSONObject outputs nothing in this situation.
It looks like to me that in order for field X to show up in the returned JSON, we have to 1. add @Property to field X; 2. make sure field X has a getter named getX.
To prove if I change to
@DataType
public class Sale {
@Property
private String guid = "1";
public Object getGuid() {
return guid;
}
}
I get
$ peer chaincode query -C mychannel -n basic -c '{"Args":["getSale"]}'
{"guid":"1"}
Suggestion
I feel this issue could be a documentation oversight as @Property didn't mention getters. If maintainers like, I can add something like
/**
* Field and parameter level annotation defining a property of the class.
*
* When this annotation applied to a field, make sure the field has a
* getter.
...
- 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
-
DataType nested classAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 75/100
hyperledger/fabric-chaincode-java#626 ·
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 119 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
Todos los issues de hyperledger/fabric-chaincode-java
Issues similares
-
[Bug] DefaultSerializationExceptionWrapper does not implement Cleanable, so cleanup() is never invoked by codecsPosiblemente ocupada @binbin0325 la tomó hoy. Abiertocomponent/need-triage type/need-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
2026 Error Report
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
triplea-game/triplea#15096 ·
Los mantenedores suelen responder en 1 día
-
[Bug][API] Switching workflow versions leaves schedules onlinePosiblemente ocupada @zhuangchong la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/dolphinscheduler#18731 ·
Los mantenedores suelen responder en 1 día
-
Implement JDBC Domain Enums (`SqlCategory`, `SqlExecutionStatus`, `SqlExecutionType`) in Core ModuleAbiertocore-module enhancement good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 87/100
sdlc-pro/spring-lens#531 ·
Los mantenedores suelen responder en 1 día