Details

    • Type: Bug
    • Status: Patch Available
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: Core Framework
    • Labels:
      None

      Description

      When using UpdateRecord and indicating a path existing in the schema but pointing to a null field, it'll throw a NullPointerException.

      Basically, NPE is thrown at:

      result.getSelectedFields().forEach(...)
      

      or

      recordPath.evaluate(record).getSelectedFields().iterator().hasNext()
      

      Stack trace:

      2017-08-31 18:21:24,202 ERROR [Timer-Driven Process Thread-5] o.a.n.processors.standard.UpdateRecord UpdateRecord[id=39158233-015e-1000-c81d-5cbd8f5cddf1] Failed to process StandardFlowFileRecord[uuid=f1807e4b-3374-4d9d-bfcf-b44ef7b6910b,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1504194471839-1, container=default, section=1], offset=63430, length=5291],offset=0,name=340191697112484,size=5291]: java.lang.NullPointerException
      java.lang.NullPointerException: null
      	at org.apache.nifi.record.path.paths.ChildFieldPath.getChild(ChildFieldPath.java:50)
      	at org.apache.nifi.record.path.paths.ChildFieldPath.lambda$evaluate$0(ChildFieldPath.java:67)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
      	at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
      	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
      	at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
      	at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
      	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
      	at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
      	at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
      	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
      	at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
      	at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
      	at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
      	at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      	at org.apache.nifi.processors.standard.UpdateRecord.process(UpdateRecord.java:168)
      	at org.apache.nifi.processors.standard.AbstractRecordProcessor$1.process(AbstractRecordProcessor.java:129)
      	at org.apache.nifi.controller.repository.StandardProcessSession.write(StandardProcessSession.java:2785)
      	at org.apache.nifi.processors.standard.AbstractRecordProcessor.onTrigger(AbstractRecordProcessor.java:118)
      	at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
      	at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1120)
      	at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:147)
      	at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47)
      	at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:132)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

        Issue Links

          Activity

          Hide
          markap14 Mark Payne added a comment -

          This same issue is likely to affect DescendantFieldPath and possibly ParentPath as well.

          Show
          markap14 Mark Payne added a comment - This same issue is likely to affect DescendantFieldPath and possibly ParentPath as well.
          Hide
          pvillard Pierre Villard added a comment -

          I had a closer a look on this one and I believe I found the root cause . It seems this error happens when you have:

          "myArray": [ null ]
          

          If you have

          "myArray": null
          

          or

          "myArray": [ ]
          

          it is correctly processed.

          The logic seems to be located in WildcardIndexPath.

          Show
          pvillard Pierre Villard added a comment - I had a closer a look on this one and I believe I found the root cause . It seems this error happens when you have: "myArray": [ null ] If you have "myArray": null or "myArray": [ ] it is correctly processed. The logic seems to be located in WildcardIndexPath .
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user pvillard31 opened a pull request:

          https://github.com/apache/nifi/pull/2122

          NIFI-4340 - fix record path evaluation when array is [ null ]

          Thank you for submitting a contribution to Apache NiFi.

          In order to streamline the review of the contribution we ask you
          to ensure the following steps have been taken:

              1. For all changes:
          • [ ] Is there a JIRA ticket associated with this PR? Is it referenced
            in the commit message?
          • [ ] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
          • [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
          • [ ] Is your initial contribution a single, squashed commit?
              1. For code changes:
          • [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
          • [ ] Have you written or updated unit tests to verify your changes?
          • [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
          • [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
          • [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
          • [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
              1. For documentation related changes:
          • [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
              1. Note:
                Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/pvillard31/nifi NIFI-4340

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/nifi/pull/2122.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #2122


          commit ad6423ee08720accf86acb14f059f9119a1d1ec8
          Author: Pierre Villard <pierre.villard.fr@gmail.com>
          Date: 2017-09-01T13:16:11Z

          NIFI-4340 - fix record path evaluation when array is [ null ]


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user pvillard31 opened a pull request: https://github.com/apache/nifi/pull/2122 NIFI-4340 - fix record path evaluation when array is [ null ] Thank you for submitting a contribution to Apache NiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: For all changes: [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? [ ] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? [ ] Is your initial contribution a single, squashed commit? For code changes: [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? [ ] Have you written or updated unit tests to verify your changes? [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0] ( http://www.apache.org/legal/resolved.html#category-a)? [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly? [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties? For documentation related changes: [ ] Have you ensured that format looks appropriate for the output in which it is rendered? Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/pvillard31/nifi NIFI-4340 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/2122.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2122 commit ad6423ee08720accf86acb14f059f9119a1d1ec8 Author: Pierre Villard <pierre.villard.fr@gmail.com> Date: 2017-09-01T13:16:11Z NIFI-4340 - fix record path evaluation when array is [ null ]
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r137869296

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -65,6 +65,7 @@
          } else {
          final Object[] array = (Object[]) value;
          return IntStream.range(0, array.length)
          + .filter(index -> array[index] != null)
          — End diff –

          @pvillard31 I don't think this is exactly right. The wildcard should include all elements, including nulls. Imagine, for example, that I have some data like:

          ```

          { "id" : 3, "numbers" : [ 1, null, 4 ] }

          ```
          If I want to set /numbers[*] to the value 8, then I would expect to get back:

          ```

          { "id" : 3, "numbers" : [ 8, 8, 8 ] }

          ```
          But with this modification I'd get back
          ```

          { "id" : 3, "numbers" : [ 8, null, 8 ] }

          ```

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r137869296 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -65,6 +65,7 @@ } else { final Object[] array = (Object[]) value; return IntStream.range(0, array.length) + .filter(index -> array [index] != null) — End diff – @pvillard31 I don't think this is exactly right. The wildcard should include all elements, including nulls. Imagine, for example, that I have some data like: ``` { "id" : 3, "numbers" : [ 1, null, 4 ] } ``` If I want to set /numbers [*] to the value 8, then I would expect to get back: ``` { "id" : 3, "numbers" : [ 8, 8, 8 ] } ``` But with this modification I'd get back ``` { "id" : 3, "numbers" : [ 8, null, 8 ] } ```
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user pvillard31 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r137950192

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -65,6 +65,7 @@
          } else {
          final Object[] array = (Object[]) value;
          return IntStream.range(0, array.length)
          + .filter(index -> array[index] != null)
          — End diff –

          Hey @markap14, thanks for the review. While I agree with your comment, it turns out (if I looked correctly) that, currently, updating an array of simple elements is not possible. If I set:
          ```
          /numbers[*]
          ````
          as the path to update with a value of 8, it won't update anything.

          I rebased against master and pushed another commit to fix the update action when updating an array of simple (not records) elements, and also to address your comment. Let me know if it looks like the right approach to you.

          Show
          githubbot ASF GitHub Bot added a comment - Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r137950192 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -65,6 +65,7 @@ } else { final Object[] array = (Object[]) value; return IntStream.range(0, array.length) + .filter(index -> array [index] != null) — End diff – Hey @markap14, thanks for the review. While I agree with your comment, it turns out (if I looked correctly) that, currently, updating an array of simple elements is not possible. If I set: ``` /numbers [*] ```` as the path to update with a value of 8, it won't update anything. I rebased against master and pushed another commit to fix the update action when updating an array of simple (not records) elements, and also to address your comment. Let me know if it looks like the right approach to you.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r138090059

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -65,9 +65,13 @@
          } else {
          final Object[] array = (Object[]) value;
          return IntStream.range(0, array.length)
          + .filter(index -> array[index] != null
          + || (((ArrayDataType) fieldValue.getField().getDataType()).getElementType()).getFieldType() != RecordFieldType.RECORD)
          — End diff –

          @pvillard31 I think this still is not exactly what we need. Even a null record should be returned when given a Wildcard. I contend that in all cases we should return the array value, null or otherwise. I think perhaps the issue that you're hitting is not related to WildcardIndexPath but rather ChildPath / DescendantPath.

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r138090059 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -65,9 +65,13 @@ } else { final Object[] array = (Object[]) value; return IntStream.range(0, array.length) + .filter(index -> array [index] != null + || (((ArrayDataType) fieldValue.getField().getDataType()).getElementType()).getFieldType() != RecordFieldType.RECORD) — End diff – @pvillard31 I think this still is not exactly what we need. Even a null record should be returned when given a Wildcard. I contend that in all cases we should return the array value, null or otherwise. I think perhaps the issue that you're hitting is not related to WildcardIndexPath but rather ChildPath / DescendantPath.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user pvillard31 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r138177766

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -65,9 +65,13 @@
          } else {
          final Object[] array = (Object[]) value;
          return IntStream.range(0, array.length)
          + .filter(index -> array[index] != null
          + || (((ArrayDataType) fieldValue.getField().getDataType()).getElementType()).getFieldType() != RecordFieldType.RECORD)
          — End diff –

          I pushed another commit to address it in ChildPath. Let me know if it sounds better.

          Show
          githubbot ASF GitHub Bot added a comment - Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r138177766 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -65,9 +65,13 @@ } else { final Object[] array = (Object[]) value; return IntStream.range(0, array.length) + .filter(index -> array [index] != null + || (((ArrayDataType) fieldValue.getField().getDataType()).getElementType()).getFieldType() != RecordFieldType.RECORD) — End diff – I pushed another commit to address it in ChildPath. Let me know if it sounds better.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r138635543

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -67,7 +67,9 @@
          return IntStream.range(0, array.length)
          .mapToObj(index -> {
          final DataType elementDataType = ((ArrayDataType) fieldValue.getField().getDataType()).getElementType();

          • final RecordField elementField = new RecordField(fieldValue.getField().getFieldName() + "[" + index + "]", elementDataType);
            + final RecordField elementField = elementDataType.getFieldType() == RecordFieldType.RECORD
              • End diff –

          @pvillard31 can you help me to understand why we're doing this? If it is a record then we include the index in the name but otherwise we don't – why not always include the index in the name?

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r138635543 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -67,7 +67,9 @@ return IntStream.range(0, array.length) .mapToObj(index -> { final DataType elementDataType = ((ArrayDataType) fieldValue.getField().getDataType()).getElementType(); final RecordField elementField = new RecordField(fieldValue.getField().getFieldName() + " [" + index + "] ", elementDataType); + final RecordField elementField = elementDataType.getFieldType() == RecordFieldType.RECORD End diff – @pvillard31 can you help me to understand why we're doing this? If it is a record then we include the index in the name but otherwise we don't – why not always include the index in the name?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user pvillard31 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r138642556

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -67,7 +67,9 @@
          return IntStream.range(0, array.length)
          .mapToObj(index -> {
          final DataType elementDataType = ((ArrayDataType) fieldValue.getField().getDataType()).getElementType();

          • final RecordField elementField = new RecordField(fieldValue.getField().getFieldName() + "[" + index + "]", elementDataType);
            + final RecordField elementField = elementDataType.getFieldType() == RecordFieldType.RECORD
              • End diff –

          This is not related to the NPE issue. It's related to my earlier comment about updating arrays of simple fields. Right now, if you try to update an array that does not contain records, it won't do anything because of the field name we're giving here. If you think that should be a separated JIRA and/or addressed differently, let me know. (I added a unit test to update an array of integers)

          Show
          githubbot ASF GitHub Bot added a comment - Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r138642556 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -67,7 +67,9 @@ return IntStream.range(0, array.length) .mapToObj(index -> { final DataType elementDataType = ((ArrayDataType) fieldValue.getField().getDataType()).getElementType(); final RecordField elementField = new RecordField(fieldValue.getField().getFieldName() + " [" + index + "] ", elementDataType); + final RecordField elementField = elementDataType.getFieldType() == RecordFieldType.RECORD End diff – This is not related to the NPE issue. It's related to my earlier comment about updating arrays of simple fields. Right now, if you try to update an array that does not contain records, it won't do anything because of the field name we're giving here. If you think that should be a separated JIRA and/or addressed differently, let me know. (I added a unit test to update an array of integers)
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/2122#discussion_r138649045

          — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java —
          @@ -67,7 +67,9 @@
          return IntStream.range(0, array.length)
          .mapToObj(index -> {
          final DataType elementDataType = ((ArrayDataType) fieldValue.getField().getDataType()).getElementType();

          • final RecordField elementField = new RecordField(fieldValue.getField().getFieldName() + "[" + index + "]", elementDataType);
            + final RecordField elementField = elementDataType.getFieldType() == RecordFieldType.RECORD
              • End diff –

          Ah ok. Yes, I think it should probably be a new JIRA. Because I suspect we will also have the same issue with ArrayIndexPath and MultiArrayIndexPath and possibly others...

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2122#discussion_r138649045 — Diff: nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/paths/WildcardIndexPath.java — @@ -67,7 +67,9 @@ return IntStream.range(0, array.length) .mapToObj(index -> { final DataType elementDataType = ((ArrayDataType) fieldValue.getField().getDataType()).getElementType(); final RecordField elementField = new RecordField(fieldValue.getField().getFieldName() + " [" + index + "] ", elementDataType); + final RecordField elementField = elementDataType.getFieldType() == RecordFieldType.RECORD End diff – Ah ok. Yes, I think it should probably be a new JIRA. Because I suspect we will also have the same issue with ArrayIndexPath and MultiArrayIndexPath and possibly others...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user pvillard31 commented on the issue:

          https://github.com/apache/nifi/pull/2122

          Pushed a new commit, rebased and squashed to only address the initial NPE issue. Will address the array update as part of NIFI-4383.

          Show
          githubbot ASF GitHub Bot added a comment - Github user pvillard31 commented on the issue: https://github.com/apache/nifi/pull/2122 Pushed a new commit, rebased and squashed to only address the initial NPE issue. Will address the array update as part of NIFI-4383 .

            People

            • Assignee:
              pvillard Pierre Villard
              Reporter:
              pvillard Pierre Villard
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development