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

Joseph Percivall commented on NIFI-5775:
----------------------------------------

[~sivaprasanna] this can be replicated in the unit tests by adding the String 
data type to the linked unit test.

To be more exact on when it'll occur, if you have a field with the ability to 
be multiple types (e.g. array + string + null) and have string as first in the 
schema type list, this will occur.

> DataTypeUtils "toString" incorrectly treats value as a "byte" when passing an 
> array leading to ClassCastException
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-5775
>                 URL: https://issues.apache.org/jira/browse/NIFI-5775
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 1.8.0
>            Reporter: Joseph Percivall
>            Priority: Major
>
> To reproduce, change this line[1] to either put "String" as the first choice 
> of record type or just set the key to use string. 
> The resulting error:
> {noformat}
> java.lang.ClassCastException: java.lang.String cannot be cast to 
> java.lang.Byte
>       at 
> org.apache.nifi.serialization.record.util.DataTypeUtils.toString(DataTypeUtils.java:530)
>       at 
> org.apache.nifi.serialization.record.util.DataTypeUtils.convertType(DataTypeUtils.java:147)
>       at 
> org.apache.nifi.serialization.record.util.DataTypeUtils.convertType(DataTypeUtils.java:115)
>       at 
> org.apache.nifi.json.WriteJsonResult.writeValue(WriteJsonResult.java:284)
>       at 
> org.apache.nifi.json.WriteJsonResult.writeRecord(WriteJsonResult.java:187)
>       at 
> org.apache.nifi.json.WriteJsonResult.writeRecord(WriteJsonResult.java:136)
>       at 
> org.apache.nifi.json.TestWriteJsonResult.testChoiceArray(TestWriteJsonResult.java:494)
> {noformat}
> [1] 
> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/json/TestWriteJsonResult.java#L479



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to