[ https://issues.apache.org/jira/browse/THRIFT-3486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gospo updated THRIFT-3486: -------------------------- Description: In case of a binary field `getFieldValue` returns a `byte[]` while `setFieldValue` expects a `ByteBuffer`. This design yields an unexpected requirement and is error prone. This is a perfectly fine use-case that a client wants to write a field value from one object to another object of the same thrift generated class: obj1.setFieldValue(SOME_FIELD, obj2.getFieldValue(SOME_FIELD)) It is a reasonable assumption that if I use a getter to obtain some property value, the corresponding setter should accept a value of the same type. Currently if `SOME_FIELD` is a binary type field an exception is thrown: java.lang.ClassCastException: [B cannot be cast to java.nio.ByteBuffer Change proposal: getFieldValue and setFieldValue behavior should be made coherent was: In case of a binary field `getFieldValue` returns a `byte[]` while `setFieldValue` expects a `ByteBuffer`. This design yields an unexpected requirement and is error prone. This is a perfectly fine use-case that a client wants to write a field value from one object to another object of the same thrift generated class: obj1.setFieldValue(SOME_FIELD, obj2.getFieldValue(SOME_FIELD)) It is a reasonable assumption that if I use a getter to obtain some property value, the corresponding setter should accept a value of the same type. Currently if `SOME_FIELD` is a binary type field an exception is thrown: java.lang.ClassCastException: [B cannot be cast to java.nio.ByteBuffer Change proposal: getFieldValue and setFieldValue behavior should be made coherent > Java generated `getFieldValue` is incompatible with `setFieldValue` for > binary values. > -------------------------------------------------------------------------------------- > > Key: THRIFT-3486 > URL: https://issues.apache.org/jira/browse/THRIFT-3486 > Project: Thrift > Issue Type: Improvement > Components: Java - Compiler > Reporter: Gospo > Priority: Minor > > In case of a binary field `getFieldValue` returns a `byte[]` while > `setFieldValue` expects a `ByteBuffer`. > This design yields an unexpected requirement and is error prone. > This is a perfectly fine use-case that a client wants to write a field value > from one object to another object of the same thrift generated class: > obj1.setFieldValue(SOME_FIELD, obj2.getFieldValue(SOME_FIELD)) > It is a reasonable assumption that if I use a getter to obtain some property > value, the corresponding setter should accept a value of the same type. > Currently if `SOME_FIELD` is a binary type field an exception is thrown: > java.lang.ClassCastException: [B cannot be cast to java.nio.ByteBuffer > Change proposal: > getFieldValue and setFieldValue behavior should be made coherent -- This message was sent by Atlassian JIRA (v6.3.4#6332)