[
https://issues.apache.org/jira/browse/NIFI-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16401072#comment-16401072
]
ASF GitHub Bot commented on NIFI-4959:
--------------------------------------
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2544#discussion_r174922021
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
---
@@ -520,6 +521,27 @@ public void onTrigger(final ProcessContext context,
final ProcessSession session
new Object[]{request.getRemoteAddr(), e});
session.remove(flowFile);
return;
+ } catch (final FlowFileAccessException e) {
+ // some bad requests can produce a IOException on the HTTP
stream, which makes a FlowFileAccessException to
+ // be thrown. We should handle these cases here, while other
FlowFileAccessException are re-thrown
+ if (!(e.getCause() != null && e.getCause() instanceof
FlowFileAccessException
--- End diff --
This logic seems very specific to me. I'm afraid that it's also quite
brittle, as well, because the wrapping of those exceptions could change at any
time. I *think* the idea here is "If you hit an IOException when reading from
the HTTP Request, then send back a BAD REQUEST status code. Else, rethrow the
Exception." Correct?
If so, we could make this a little cleaner and more stable, IMO, if we
change the logic above a little bit. Instead of calling
`ProcessSession.importFrom(InputStream, FlowFile)` (which would throw
FlowFileAccessException if any IOException is thrown), we can change it to
something like:
```
try (OutputStream flowFileOut = session.write(flowFile)) {
StreamUtils.copy(request.getInputStream(), flowFileOut);
} catch (IOException ioe) {
// this will occur only if an IOException is thrown from reading the
InputStream. If an IOException is thrown from
// the OutputStream, the OutputStream will always wrap it with a
FlowFileAccessException because this is
// a "special case" where we are writing to the Content Repo.
// ... new logic here to remove flowfile and send back bad request
status code
}
```
> HandleHttpRequest processor doesn't close/release incomplete message error
> --------------------------------------------------------------------------
>
> Key: NIFI-4959
> URL: https://issues.apache.org/jira/browse/NIFI-4959
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.5.0, 1.6.0
> Environment: Linux, all versions of nifi-1.X
> Reporter: Wynner
> Priority: Major
>
> I am doing some testing with the HandleHttpRequest processor. My specific
> test, involves sending an incomplete request and closing the connection from
> the sending system. Initially, it throws the error I expect, but it keeps
> throwing the error over and over based on the request expiration configured
> in the StandardHttpContextMap controller service.
> The only way to stop the error message is to stop the processor. In my test,
> I saw one failed request throw an error six times before I stopped the
> processor.
> It doesn't seems to terminate the request on the NiFi side.
> Sample HTTP request
>
> POST/ HTTP/ 1.1
> Host: foo.com
> Content-Type: text/plain
> Content-Length: 130
> say=Hi&to-Mom
>
> I use the telnet command to connect to the system with the processor
> listening, post the message above , close the connection, and then the
> processor starts throws the following error indefinitely
> 2018-03-10 01:36:37,111 ERROR [Timer-Driven Process Thread-6]
> o.a.n.p.standard.HandleHttpRequest
> HandleHttpRequest[id=0d8547f7-0162-1000-9b84-129af2382259]
> HandleHttpRequest[id=0d8547f7-0162-1000-9b84-129af2382259] failed to process
> session due to org.apache.nifi.processor.exception.FlowFileAccessException:
> Failed to import data from
> HttpInputOverHTTP@46e7d12e[c=15,q=0,[0]=null,s=EARLY_EOF] for
> StandardFlowFileRecord[uuid=32bb182d-f619-4b98-b6f8-c1ed50c2736a,claim=,offset=0,name=9714775822613527,size=0]
> due to org.apache.nifi.processor.exception.FlowFileAccessException: Unable
> to create ContentClaim due to org.eclipse.jetty.io.EofException: Early EOF: {}
> org.apache.nifi.processor.exception.FlowFileAccessException: Failed to
> import data from HttpInputOverHTTP@46e7d12e[c=15,q=0,[0]=null,s=EARLY_EOF]
> for
> StandardFlowFileRecord[uuid=32bb182d-f619-4b98-b6f8-c1ed50c2736a,claim=,offset=0,name=9714775822613527,size=0]
> due to org.apache.nifi.processor.exception.FlowFileAccessException: Unable
> to create ContentClaim due to org.eclipse.jetty.io.EofException: Early EOF
> at
> org.apache.nifi.controller.repository.StandardProcessSession.importFrom(StandardProcessSession.java:2942)
> at
> org.apache.nifi.processors.standard.HandleHttpRequest.onTrigger(HandleHttpRequest.java:517)
> at
> org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
> at
> org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1123)
> at
> org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:147)
> at
> org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47)
> at
> org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:128)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
> at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
> at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: org.apache.nifi.processor.exception.FlowFileAccessException:
> Unable to create ContentClaim due to org.eclipse.jetty.io.EofException: Early
> EOF
> at
> org.apache.nifi.controller.repository.StandardProcessSession.importFrom(StandardProcessSession.java:2935)
> ... 13 common frames omitted
> Caused by: org.eclipse.jetty.io.EofException: Early EOF
> at org.eclipse.jetty.server.HttpInput$3.getError(HttpInput.java:1104)
> at org.eclipse.jetty.server.HttpInput$3.noContent(HttpInput.java:1093)
> at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:307)
> at java.io.InputStream.read(InputStream.java:101)
> at org.apache.nifi.stream.io.StreamUtils.copy(StreamUtils.java:35)
> at
> org.apache.nifi.controller.repository.FileSystemRepository.importFrom(FileSystemRepository.java:734)
> at org.apache.nifi.controller
>
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)