Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5974

SplitContent: missing Fragment Attributes if the splitter wasn't found

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.9.0
    • Extensions
    • None

    Description

      If there is no splitter in the input Flow File and nothing was changed the Fragment Attributes are missing in the result. That breaks the MergeContent processor as it doesn't know how many fragments are expected.
      For example if the splitter is "," and the targed content is "UVAT" there are no fragment.count, fragment.identifier, fragment.index, segment.original.filename attributes in the result.

      Expected result: "splits" flow file has mentioned attributes.
      Here is a "red" test:

      @Test
      public void testNoSplitterInString() {
      	
      	String content = "UVAT";
      	
      	final TestRunner runner = TestRunners.newTestRunner(new SplitContent());
      	runner.setProperty(SplitContent.FORMAT, SplitContent.UTF8_FORMAT.getValue());
      	runner.setProperty(SplitContent.BYTE_SEQUENCE, ",");
      	runner.setProperty(SplitContent.KEEP_SEQUENCE, "false");
      	runner.setProperty(SplitContent.BYTE_SEQUENCE_LOCATION, SplitContent.TRAILING_POSITION.getValue());
      
      	runner.enqueue(content.getBytes());
      	runner.run();
      
      	runner.assertTransferCount(SplitContent.REL_SPLITS, 1);
      	MockFlowFile splitResult = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS).get(0);
      	splitResult.assertAttributeExists(FRAGMENT_ID);
      	splitResult.assertAttributeExists(SEGMENT_ORIGINAL_FILENAME);
      	splitResult.assertAttributeEquals(FRAGMENT_COUNT, "1");
      	splitResult.assertAttributeEquals(FRAGMENT_INDEX, "1");
      	runner.assertTransferCount(SplitContent.REL_ORIGINAL, 1);
      
      	runner.assertQueueEmpty();
      	final List<MockFlowFile> splits = runner.getFlowFilesForRelationship(SplitContent.REL_SPLITS);
      	splits.get(0).assertContentEquals(content);
      }
      

      The fix is ready, pending PR

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              adurov Alexey Durov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m