[
https://issues.apache.org/jira/browse/NIFI-5765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16668045#comment-16668045
]
ASF GitHub Bot commented on NIFI-5765:
--------------------------------------
Github user ijokarumawak commented on a diff in the pull request:
https://github.com/apache/nifi/pull/3114#discussion_r229158995
--- Diff:
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/json/TestWriteJsonResult.java
---
@@ -472,4 +472,34 @@ public void testOnelineOutput() throws IOException {
final String output = new String(data, StandardCharsets.UTF_8);
assertEquals(expected, output);
}
+
+ @Test
+ public void testChoiceArray() throws IOException {
+ final List<RecordField> fields = new ArrayList<>();
+ fields.add(new RecordField("path",
RecordFieldType.CHOICE.getChoiceDataType(RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.STRING.getDataType()))));
+ //fields.add(new RecordField("path",
RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.STRING.getDataType())));
--- End diff --
I'll remove this comment line when I merge this.
> WriteJsonResult fails with Class Cast Exception when Choice data type
> resolves to Array
> ---------------------------------------------------------------------------------------
>
> Key: NIFI-5765
> URL: https://issues.apache.org/jira/browse/NIFI-5765
> Project: Apache NiFi
> Issue Type: Bug
> Affects Versions: 1.8.0
> Reporter: Joseph Percivall
> Assignee: Joseph Percivall
> Priority: Major
> Attachments: Screen Shot 2018-10-29 at 2.35.50 PM.png,
> WriteJsonResult_Choice_Array_example.xml
>
>
> The problem is this line[1]. For the casting, it uses the passed in value
> instead of the chosen data type.
> A template demonstrating the problem is attached. The corner case is hit when
> there is a choice of data types, and the data type chosen is Array. It
> properly does everything else but fails when casting it due to:
> org.apache.nifi.serialization.record.type.ChoiceDataType cannot be cast to
> org.apache.nifi.serialization.record.type.ArrayDataType.
> [1]
> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/json/WriteJsonResult.java#L379
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)