[
https://issues.apache.org/jira/browse/NIFI-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14368548#comment-14368548
]
ASF GitHub Bot commented on NIFI-396:
-------------------------------------
GitHub user rowolabi opened a pull request:
https://github.com/apache/incubator-nifi/pull/39
NIFI-396: StandardProcessSession allows InputStream to be accessed after
returning from callback
Contains fix to prevent clients of the ProcessSession from accessing the
Input/Output Streams it provides once callbacks complete their execution:
- Created a DisableOnCloseInputStream and modified StandardProcessSession
to utilize it
- Updated ProcessSession's javadoc
- Added tests
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rowolabi/incubator-nifi
inputstream-callback-protection
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-nifi/pull/39.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 #39
----
commit 7272d0df58c23d099809bf96993b55d73c617476
Author: Bobby Owolabi <[email protected]>
Date: 2015-03-19T03:30:57Z
NIFI-396 created tests to demonstrate the situations where the
ProcessSession throws an Exception and where it doesn't after it returns from
the callback
commit e2760f8c980583d285137134e05c435c930fb4d2
Author: Bobby Owolabi <[email protected]>
Date: 2015-03-19T04:54:24Z
NIFI-396 added a DisableOnCloseInputStream class; modified
StandardProcessSession to prevent access of the Input/OutputStreams after
callbacks have been executed; updated tests
commit cd183be4410bdc88de7d3a0026452ab62eb10621
Author: Bobby Owolabi <[email protected]>
Date: 2015-03-19T05:18:22Z
NIFI-396 updated the javadocs of ProcessSession to reflect that a
FlowFileAccessExcpetion will be thrown if an Input/Output Stream is attempted
to be accessed after the callback is executed.
commit 3f3623647367421cd8eb318668144aca1afb9bf4
Author: Bobby Owolabi <[email protected]>
Date: 2015-03-19T05:43:17Z
NIFI-396 reverting accidentially modified whitespace in
TestStandardProcessSession
----
> StandardProcessSession allows InputStream to be accessed after returning from
> callback
> --------------------------------------------------------------------------------------
>
> Key: NIFI-396
> URL: https://issues.apache.org/jira/browse/NIFI-396
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Reporter: Mark Payne
> Labels: beginner
>
> When StandardProcessSession.read(FlowFile, InputStreamCallback) or
> StandardProcessSession.write(FlowFile, StreamCallback) is called, the
> InputStream that is provided to the callback can be accessed after returning
> from the callback. For example:
> final ObjectHolder<InputStream> inputStreamHolder = new ObjectHolder<>(null);
> session.read(flowFile, new InputStreamCallback() {
> @Override
> public void process(InputStream in) throws IOException {
> inputStreamHolder.set(in);
> }
> });
> // read from inputStreamHolder.get()
> At this point, attempting to read from inputStreamHolder.get() should throw
> an IOException but does not.
> This is because the stream that is returned by StandardProcessSession is
> wrapping a NonCloseableInputStream. This NonCloseableInputStream should
> instead be a DisableOnCloseInputStream (which does not exist but should be
> written in a very similar fashion to DisableOnCloseOutputStream).
> The JavaDocs for ProcessSession should also be updated to indicate that the
> streams provided will be managed by the framework and will not be accessible
> once the callback returns.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)