You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/12/22 19:05:00 UTC

[GitHub] [nifi] mattyb149 opened a new pull request, #6803: NIFI-10998: Fix SplitJson to always compile new JsonPath when property changes

mattyb149 opened a new pull request, #6803:
URL: https://github.com/apache/nifi/pull/6803

   # Summary
   
   [NIFI-10998](https://issues.apache.org/jira/browse/NIFI-10998) This PR removes the check for `oldValue == null` before compiling and caching the new JsonPath value
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [x] Pull Request based on current revision of the `main` branch
   - [x] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
     - [ ] JDK 8
     - [x] JDK 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory closed pull request #6803: NIFI-10998: Fix SplitJson to always compile new JsonPath when property changes

Posted by GitBox <gi...@apache.org>.
exceptionfactory closed pull request #6803: NIFI-10998: Fix SplitJson to always compile new JsonPath when property changes
URL: https://github.com/apache/nifi/pull/6803


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] Lehel44 commented on a diff in pull request #6803: NIFI-10998: Fix SplitJson to always compile new JsonPath when property changes

Posted by GitBox <gi...@apache.org>.
Lehel44 commented on code in PR #6803:
URL: https://github.com/apache/nifi/pull/6803#discussion_r1056360444


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java:
##########
@@ -112,6 +112,43 @@ public void testSplit_arrayResult_multipleValues() throws Exception {
         originalOut.assertContentEquals(JSON_SNIPPET);
     }
 
+    @Test
+    public void testSplit_change_jsonpath() throws Exception {
+        final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
+        testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range");
+
+        testRunner.enqueue(JSON_SNIPPET);
+        testRunner.run();
+
+        int numSplitsExpected = 10;
+
+        testRunner.assertTransferCount(SplitJson.REL_ORIGINAL, 1);
+        testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0).assertAttributeEquals(FRAGMENT_COUNT.key(), String.valueOf(numSplitsExpected));
+        testRunner.assertTransferCount(SplitJson.REL_SPLIT, numSplitsExpected);
+        final MockFlowFile originalOut = testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0);
+        originalOut.assertContentEquals(JSON_SNIPPET);
+
+        // Change JsonPath Expression, verify it is being applied correctly
+        testRunner.clearTransferState();
+        testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[*].name");
+
+        testRunner.enqueue(JSON_SNIPPET, new HashMap<>() {
+            {
+                put(CoreAttributes.FILENAME.key(), "test.json");
+            }
+        });

Review Comment:
   Using diamond with anonymous inner classes is not supported for some reason, this change fixes the build, too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6803: NIFI-10998: Fix SplitJson to always compile new JsonPath when property changes

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6803:
URL: https://github.com/apache/nifi/pull/6803#discussion_r1055920409


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java:
##########
@@ -112,6 +112,43 @@ public void testSplit_arrayResult_multipleValues() throws Exception {
         originalOut.assertContentEquals(JSON_SNIPPET);
     }
 
+    @Test
+    public void testSplit_change_jsonpath() throws Exception {
+        final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
+        testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range");
+
+        testRunner.enqueue(JSON_SNIPPET);
+        testRunner.run();
+
+        int numSplitsExpected = 10;
+
+        testRunner.assertTransferCount(SplitJson.REL_ORIGINAL, 1);
+        testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0).assertAttributeEquals(FRAGMENT_COUNT.key(), String.valueOf(numSplitsExpected));
+        testRunner.assertTransferCount(SplitJson.REL_SPLIT, numSplitsExpected);
+        final MockFlowFile originalOut = testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0);
+        originalOut.assertContentEquals(JSON_SNIPPET);
+
+        // Change JsonPath Expression, verify it is being applied correctly
+        testRunner.clearTransferState();
+        testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[*].name");
+
+        testRunner.enqueue(JSON_SNIPPET, new HashMap<>() {
+            {
+                put(CoreAttributes.FILENAME.key(), "test.json");
+            }
+        });

Review Comment:
   This can be simplified using `Collections.singletonMap`
   ```suggestion
           testRunner.enqueue(JSON_SNIPPET, Collections.singletonMap(CoreAttributes.FILENAME.key(), "test.json"));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org