Repository: nifi
Updated Branches:
  refs/heads/master 31b943d2c -> 3d3faada5


NIFI-3408 Add exception class when InvokeHTTP fails


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

Branch: refs/heads/master
Commit: 3d3faada5c614b4ac40c866775492fa6b7e202e3
Parents: 31b943d
Author: Giovanni Lanzani <[email protected]>
Authored: Thu Feb 2 16:49:15 2017 +0100
Committer: Pierre Villard <[email protected]>
Committed: Tue Feb 7 09:04:48 2017 +0100

----------------------------------------------------------------------
 .../apache/nifi/processors/standard/InvokeHTTP.java   | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/3d3faada/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
index bb5b3b5..c3d7fe9 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
@@ -104,7 +104,8 @@ import org.joda.time.format.DateTimeFormatter;
     @WritesAttribute(attribute = "invokehttp.request.url", description = "The 
request URL"),
     @WritesAttribute(attribute = "invokehttp.tx.id", description = "The 
transaction ID that is returned after reading the response"),
     @WritesAttribute(attribute = "invokehttp.remote.dn", description = "The DN 
of the remote server"),
-    @WritesAttribute(attribute = "invokehttp.java.exception", description = 
"The Java exception raised when the processor fails"),
+    @WritesAttribute(attribute = "invokehttp.java.exception.class", 
description = "The Java exception class raised when the processor fails"),
+    @WritesAttribute(attribute = "invokehttp.java.exception.message", 
description = "The Java exception message raised when the processor fails"),
     @WritesAttribute(attribute = "user-defined", description = "If the 'Put 
Response Body In Attribute' property is set then whatever it is set to "
         + "will become the attribute key and the value would be the body of 
the HTTP response.")})
 @DynamicProperty(name = "Header Name", value = "Attribute Expression 
Language", supportsExpressionLanguage = true, description = "Send request 
header "
@@ -119,7 +120,8 @@ public final class InvokeHTTP extends AbstractProcessor {
     public final static String REQUEST_URL = "invokehttp.request.url";
     public final static String TRANSACTION_ID = "invokehttp.tx.id";
     public final static String REMOTE_DN = "invokehttp.remote.dn";
-    public final static String EXCEPTION_CLASS = "invokehttp.java.exception";
+    public final static String EXCEPTION_CLASS = 
"invokehttp.java.exception.class";
+    public final static String EXCEPTION_MESSAGE = 
"invokehttp.java.exception.message";
 
 
     public static final String DEFAULT_CONTENT_TYPE = 
"application/octet-stream";
@@ -129,7 +131,8 @@ public final class InvokeHTTP extends AbstractProcessor {
     // This set includes our strings defined above as well as some standard 
flowfile
     // attributes.
     public static final Set<String> IGNORED_ATTRIBUTES = 
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
-            STATUS_CODE, STATUS_MESSAGE, RESPONSE_BODY, REQUEST_URL, 
TRANSACTION_ID, REMOTE_DN, EXCEPTION_CLASS,
+            STATUS_CODE, STATUS_MESSAGE, RESPONSE_BODY, REQUEST_URL, 
TRANSACTION_ID, REMOTE_DN,
+            EXCEPTION_CLASS, EXCEPTION_MESSAGE,
             "uuid", "filename", "path")));
 
     // properties
@@ -756,9 +759,8 @@ public final class InvokeHTTP extends AbstractProcessor {
             if (requestFlowFile != null) {
                 logger.error("Routing to {} due to exception: {}", new 
Object[]{REL_FAILURE.getName(), e}, e);
                 requestFlowFile = session.penalize(requestFlowFile);
-                String attributeKey = EXCEPTION_CLASS;
-                String attributeValue = e.getClass().getName();
-                requestFlowFile = session.putAttribute(requestFlowFile, 
attributeKey, attributeValue);
+                requestFlowFile = session.putAttribute(requestFlowFile, 
EXCEPTION_CLASS, e.getClass().getName());
+                requestFlowFile = session.putAttribute(requestFlowFile, 
EXCEPTION_MESSAGE, e.getMessage());
                 // transfer original to failure
                 session.transfer(requestFlowFile, REL_FAILURE);
             } else {

Reply via email to