[ 
https://issues.apache.org/jira/browse/AVRO-2641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17029953#comment-17029953
 ] 

ASF subversion and git services commented on AVRO-2641:
-------------------------------------------------------

Commit f25dc7c49457c75307a0257c90bf58eda9b19148 in avro's branch 
refs/heads/branch-1.9 from Magne Helleborg
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=f25dc7c ]

AVRO-2641: Fix for SpecificRecord String deserialization (#728)

* AVRO-2641: Fix for SpecificRecord String deserialization

Changed from casting object to String when schema expects String field.
Since Avro can represent Strings in Java as either String,
CharSequence or org.apache.avro.util.Utf8,the put can fail
with a ClassCastException.
By changing from cast to toString() the issue is circumvented.

* Apply suggestions from code review

Added spacing for legibility as suggested.

Co-Authored-By: Fokko Driesprong <[email protected]>

* AVRO-2641: Whitespace fixes for unit tests.

Co-authored-by: Fokko Driesprong <[email protected]>
Co-authored-by: RyanSkraba <[email protected]>


> Generated code results in java.lang.ClassCastException when deserializing
> -------------------------------------------------------------------------
>
>                 Key: AVRO-2641
>                 URL: https://issues.apache.org/jira/browse/AVRO-2641
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.8.0
>            Reporter: Magne Moss Helleborg
>            Assignee: Magne Moss Helleborg
>            Priority: Critical
>             Fix For: 1.9.2
>
>
> SpecificRecord put() used by datumreader does not account for that String 
> fields can be represented as org.apache.avro.util.Utf8 or other CharSequence 
> which might not be castable to java.lang.String.
> The result is that  when it tries to deserialize Utf8-fields it fails with a 
> ClassCastException.
> Proposed solution: toString() instead of cast for Strings.
>  
> To reproduce error: Serialize schema with String definitions from the .Net 
> Avro library, ex Confluent.Apache.Avro. It will default to UTF-8 for strings, 
> and fail when deserializing the same schema from the JVM.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to