[
https://issues.apache.org/jira/browse/NIFI-1866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15285347#comment-15285347
]
ASF GitHub Bot commented on NIFI-1866:
--------------------------------------
Github user pvillard31 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/439#discussion_r63429069
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/StandardProcessSession.java
---
@@ -2308,18 +2308,50 @@ public void exportTo(final FlowFile source, final
Path destination, final boolea
public void exportTo(final FlowFile source, final OutputStream
destination) {
validateRecordState(source);
final StandardRepositoryRecord record = records.get(source);
+
+ if(record.getCurrentClaim() == null) {
+ return;
+ }
+
try {
- if (record.getCurrentClaim() == null) {
- return;
+ ensureNotAppending(record.getCurrentClaim());
+ } catch (final IOException e) {
+ throw new FlowFileAccessException("Failed to access
ContentClaim for " + source.toString(), e);
+ }
+
+ try (final InputStream rawIn = getInputStream(source,
record.getCurrentClaim(), record.getCurrentClaimOffset());
+ final InputStream limitedIn = new
LimitedInputStream(rawIn, source.getSize());
+ final InputStream disableOnCloseIn = new
DisableOnCloseInputStream(limitedIn);
+ final ByteCountingInputStream countingStream = new
ByteCountingInputStream(disableOnCloseIn, this.bytesRead)) {
+
+ // We want to differentiate between IOExceptions thrown by the
repository and IOExceptions thrown from
+ // Processor code. As a result, as have the
FlowFileAccessInputStream that catches IOException from the repository
+ // and translates into either FlowFileAccessException or
ContentNotFoundException. We keep track of any
+ // ContentNotFoundException because if it is thrown, the
Processor code may catch it and do something else with it
+ // but in reality, if it is thrown, we want to know about it
and handle it, even if the Processor code catches it.
+ final FlowFileAccessInputStream ffais = new
FlowFileAccessInputStream(countingStream, source, record.getCurrentClaim());
+ boolean cnfeThrown = false;
+
+ try {
+ recursionSet.add(source);
+ StreamUtils.skip(ffais, record.getCurrentClaimOffset());
--- End diff --
Correct @markap14. I updated and rebased the PR taking into account your
comments.
> Exception thrown by StandardProcessSession.exportTo implies issues reading
> from repository
> ------------------------------------------------------------------------------------------
>
> Key: NIFI-1866
> URL: https://issues.apache.org/jira/browse/NIFI-1866
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Reporter: Mark Payne
> Assignee: Mark Payne
> Fix For: 0.7.0
>
>
> When calling ProcessSession.exportTo, if unable to write to the OutputStream
> provided, we end up with a FlowFileAccessException, rather than IOException.
> This implies that we were unable to access the ContentRepository, but this is
> not accurate. We need to ensure that we throw the appropriate Exception here
> so that Processors that cause ProcessException are able to handle the
> Exception properly
> 23:23:03,338 ERROR Timer-Driven Process Thread-3
> standard.HandleHttpResponse:306 -
> org.apache.nifi.processor.exception.FlowFileAccessException: Failed to export
> StandardFlowFileRecord[uuid=366b3598-a1f7-446e-83b6-9d0404532691,claim=StandardContentClaim
> [resourceClaim=StandardResourceClaim[id=1462828983178-2, container=default,
> section=2], offset=49798,
> length=51200000],offset=0,name=1095188501442536,size=51200000] to
> HttpOutput@1eb25c5d{OPEN} due to org.eclipse.jetty.io.EofException
> at
> org.apache.nifi.controller.repository.StandardProcessSession.exportTo(StandardProcessSession.java:2322)
> at
> org.apache.nifi.processors.standard.HandleHttpResponse.onTrigger(HandleHttpResponse.java:166)
> at
> org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)