You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by br...@apache.org on 2017/01/13 23:11:43 UTC

nifi git commit: NIFI-3330 Replaced two instances of multiple calls to getter methods during request attribute retrieval with a single call saved to a local variable to prevent null pointer exceptions during multiple invocations of a getter method.

Repository: nifi
Updated Branches:
  refs/heads/master 4d533a99b -> def4918af


NIFI-3330 Replaced two instances of multiple calls to getter methods during request attribute retrieval with a single call saved to a local variable to prevent null pointer exceptions during multiple invocations of a getter method.

This closes #1415.

Signed-off-by: Bryan Rosander <br...@apache.org>


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

Branch: refs/heads/master
Commit: def4918af0fc448726f8725b6ea3bb8636310795
Parents: 4d533a9
Author: Jeff Storck <jt...@gmail.com>
Authored: Fri Jan 13 17:03:24 2017 -0500
Committer: Bryan Rosander <br...@apache.org>
Committed: Fri Jan 13 18:09:28 2017 -0500

----------------------------------------------------------------------
 .../nifi/processors/standard/HandleHttpRequest.java     | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/def4918a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
index c1acc85..19fa943 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
 import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
 import javax.servlet.ServletException;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
@@ -512,8 +513,9 @@ public class HandleHttpRequest extends AbstractProcessor {
             putAttribute(attributes, "http.method", request.getMethod());
             putAttribute(attributes, "http.local.addr", request.getLocalAddr());
             putAttribute(attributes, HTTPUtils.HTTP_LOCAL_NAME, request.getLocalName());
-            if (request.getQueryString() != null) {
-                putAttribute(attributes, "http.query.string", URLDecoder.decode(request.getQueryString(), charset));
+            final String queryString = request.getQueryString();
+            if (queryString != null) {
+                putAttribute(attributes, "http.query.string", URLDecoder.decode(queryString, charset));
             }
             putAttribute(attributes, HTTPUtils.HTTP_REMOTE_HOST, request.getRemoteHost());
             putAttribute(attributes, "http.remote.addr", request.getRemoteAddr());
@@ -523,8 +525,9 @@ public class HandleHttpRequest extends AbstractProcessor {
             putAttribute(attributes, "http.auth.type", request.getAuthType());
 
             putAttribute(attributes, "http.requested.session.id", request.getRequestedSessionId());
-            if (request.getDispatcherType() != null) {
-                putAttribute(attributes, "http.dispatcher.type", request.getDispatcherType().name());
+            final DispatcherType dispatcherType = request.getDispatcherType();
+            if (dispatcherType != null) {
+                putAttribute(attributes, "http.dispatcher.type", dispatcherType.name());
             }
             putAttribute(attributes, "http.character.encoding", request.getCharacterEncoding());
             putAttribute(attributes, "http.locale", request.getLocale());
@@ -552,7 +555,6 @@ public class HandleHttpRequest extends AbstractProcessor {
                 }
             }
 
-            final String queryString = request.getQueryString();
             if (queryString != null) {
                 final String[] params = URL_QUERY_PARAM_DELIMITER.split(queryString);
                 for (final String keyValueString : params) {