Ryan Skraba created AVRO-4255:
---------------------------------
Summary: [Jav] BigDecimal cannot be cast to class
java.nio.ByteBuffer
Key: AVRO-4255
URL: https://issues.apache.org/jira/browse/AVRO-4255
Project: Apache Avro
Issue Type: Bug
Reporter: Ryan Skraba
(From this PR: https://github.com/apache/avro/pull/3616#issuecomment-3733774083)
java.lang.ClassCastException: class java.math.BigDecimal cannot be cast to
class java.nio.ByteBuffer
This is because the schema has a bytes field annotated with the decimal logical
type, but the POJO is generated via maven avro plugin with
enableDecimalLogicalType = false (the default) and so the receiving instance
field type java.nio.ByteBuffer is miss-matched.
[This|https://github.com/apache/avro/blob/cbc457da80df85336e1ee792cbbcbb02513dbeb9/lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java#L249-L265]
logic is responsible for attaching conversions based on schema logical type
annotations; a possible fix would involve interrogating the receiving instance
via reflection for receiving field type and matching this with what's returned
from Conversion.getConvertedType() or simply an informational/documentation fix
stating that schema logical type annotations have to be accompanied by
enableDecimalLogicalType = true setting in the avro compiler.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)