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

Nested ProcessSession.read resulting in outer stream being closed.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 1.6.0
    • 1.7.0
    • Core Framework
    • None

    Description

      Consider this example processor:

      FlowFile ff1 = session.write(session.create(),
          (out) -> { out.write(new byte[]{ 'A', 'B' }); });
      FlowFile ff2 = session.write(session.create(),
          (out) -> { out.write('C'); });
      
      session.read(ff1,
          (in1) -> {
              int a = in1.read();
              session.read(ff2, (in2) -> { int c = in2.read(); });
              int b = in1.read();
          });
      
      session.transfer(ff1, REL_SUCCESS);
      session.transfer(ff2, REL_SUCCESS);

      The expectation is that a='A', b='B' and c='C'.

      The actual result is that the final call to in1.read() throws due to the underlying stream being closed by the previous session.read on ff2.

      A workaround seems to be to pass the optional parameter to session.read of allowSessionStreamManagement=true.

      Is this expected that nested reads used in this way will not work?

      Attachments

        Activity

          People

            markap14 Mark Payne
            peterr Peter Radden
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: