nifi git commit: NIFI-3517 If HandleHttpResponse cannot write response remove entry from HttpContextMap. * Add test for failure not clear context map. * Add handler to remove context map entry if Proc

2017-05-01 Thread mosermw
Repository: nifi
Updated Branches:
  refs/heads/0.x 8a18d2666 -> ceec0ecfd


NIFI-3517 If HandleHttpResponse cannot write response remove entry from 
HttpContextMap.
* Add test for failure not clear context map.
* Add handler to remove context map entry if ProcessException occurs during 
while exporting response.

Signed-off-by: Mike Moser 

This closes #1567.


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/ceec0ecf
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/ceec0ecf
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/ceec0ecf

Branch: refs/heads/0.x
Commit: ceec0ecfd75d1c5387f98278b11278e497ca8428
Parents: 8a18d26
Author: Joe Skora 
Authored: Mon Mar 6 20:25:06 2017 -0500
Committer: Mike Moser 
Committed: Mon May 1 20:43:29 2017 +

--
 .../processors/standard/HandleHttpResponse.java |  5 +++
 .../standard/TestHandleHttpResponse.java| 41 +---
 2 files changed, 40 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/nifi/blob/ceec0ecf/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
--
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
index e15abcc..2244ca6 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
@@ -165,6 +165,11 @@ public class HandleHttpResponse extends AbstractProcessor {
 try {
 session.exportTo(flowFile, response.getOutputStream());
 response.flushBuffer();
+} catch (final ProcessException e) {
+session.transfer(flowFile, REL_FAILURE);
+getLogger().error("Failed to respond to HTTP request for {} due to 
{}", new Object[]{flowFile, e});
+contextMap.complete(contextIdentifier);
+return;
 } catch (final Exception e) {
 session.transfer(flowFile, REL_FAILURE);
 getLogger().error("Failed to respond to HTTP request for {} due to 
{}", new Object[]{flowFile, e});

http://git-wip-us.apache.org/repos/asf/nifi/blob/ceec0ecf/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
--
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
index bdf1cdc..ba402d4 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
@@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.nifi.controller.AbstractControllerService;
 import org.apache.nifi.http.HttpContextMap;
 import org.apache.nifi.processor.exception.FlowFileAccessException;
+import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.processors.standard.util.HTTPUtils;
 import org.apache.nifi.provenance.ProvenanceEventType;
 import org.apache.nifi.reporting.InitializationException;
@@ -56,7 +57,7 @@ public class TestHandleHttpResponse {
 public void testEnsureCompleted() throws InitializationException {
 final TestRunner runner = 
TestRunners.newTestRunner(HandleHttpResponse.class);
 
-final MockHttpContextMap contextMap = new MockHttpContextMap("my-id", 
false);
+final MockHttpContextMap contextMap = new MockHttpContextMap("my-id", 
"");
 runner.addControllerService("http-context-map", contextMap);
 runner.enableControllerService(contextMap);
 runner.setProperty(HandleHttpResponse.HTTP_CONTEXT_MAP, 
"http-context-map");
@@ -95,7 +96,7 @@ public class TestHandleHttpResponse {
 public void testWithExceptionThrown() throws InitializationException {
 final TestRunner runner = 
TestRunners.newTestRunner(HandleHttpResponse.class);
 
-final MockHttpContextMap contextMap = new MockHttpContex

nifi git commit: NIFI-3517 If HandleHttpResponse cannot write response remove entry from HttpContextMap. * Add test for failure not clear context map. * Add handler to remove context map entry if Proc

2017-03-08 Thread pvillard
Repository: nifi
Updated Branches:
  refs/heads/master 1376e5fbd -> 90ff275bb


NIFI-3517 If HandleHttpResponse cannot write response remove entry from 
HttpContextMap.
* Add test for failure not clear context map.
* Add handler to remove context map entry if ProcessException occurs during 
while exporting response.

Signed-off-by: Pierre Villard 

This closes #1567.


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/90ff275b
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/90ff275b
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/90ff275b

Branch: refs/heads/master
Commit: 90ff275bb9d792c97dc1c1ece3262a36b79bf623
Parents: 1376e5f
Author: Joe Skora 
Authored: Mon Mar 6 20:25:06 2017 -0500
Committer: Pierre Villard 
Committed: Wed Mar 8 13:16:58 2017 +0100

--
 .../processors/standard/HandleHttpResponse.java |  5 +++
 .../standard/TestHandleHttpResponse.java| 41 +---
 2 files changed, 40 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/nifi/blob/90ff275b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
--
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
index e15abcc..2244ca6 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java
@@ -165,6 +165,11 @@ public class HandleHttpResponse extends AbstractProcessor {
 try {
 session.exportTo(flowFile, response.getOutputStream());
 response.flushBuffer();
+} catch (final ProcessException e) {
+session.transfer(flowFile, REL_FAILURE);
+getLogger().error("Failed to respond to HTTP request for {} due to 
{}", new Object[]{flowFile, e});
+contextMap.complete(contextIdentifier);
+return;
 } catch (final Exception e) {
 session.transfer(flowFile, REL_FAILURE);
 getLogger().error("Failed to respond to HTTP request for {} due to 
{}", new Object[]{flowFile, e});

http://git-wip-us.apache.org/repos/asf/nifi/blob/90ff275b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
--
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
index bdf1cdc..ba402d4 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestHandleHttpResponse.java
@@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.nifi.controller.AbstractControllerService;
 import org.apache.nifi.http.HttpContextMap;
 import org.apache.nifi.processor.exception.FlowFileAccessException;
+import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.processors.standard.util.HTTPUtils;
 import org.apache.nifi.provenance.ProvenanceEventType;
 import org.apache.nifi.reporting.InitializationException;
@@ -56,7 +57,7 @@ public class TestHandleHttpResponse {
 public void testEnsureCompleted() throws InitializationException {
 final TestRunner runner = 
TestRunners.newTestRunner(HandleHttpResponse.class);
 
-final MockHttpContextMap contextMap = new MockHttpContextMap("my-id", 
false);
+final MockHttpContextMap contextMap = new MockHttpContextMap("my-id", 
"");
 runner.addControllerService("http-context-map", contextMap);
 runner.enableControllerService(contextMap);
 runner.setProperty(HandleHttpResponse.HTTP_CONTEXT_MAP, 
"http-context-map");
@@ -95,7 +96,7 @@ public class TestHandleHttpResponse {
 public void testWithExceptionThrown() throws InitializationException {
 final TestRunner runner = 
TestRunners.newTestRunner(HandleHttpResponse.class);
 
-final MockHttpContextMap contextMap = new