Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 5285c8be7 -> fb6a71318


AMBARI-18588 Ambari server should not crash with NPE when parsing HTTP response 
for YARN RM properties (dili)


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

Branch: refs/heads/branch-2.5
Commit: fb6a71318efd1fbeb936f02c42462e9bce9bf716
Parents: 5285c8b
Author: Di Li <d...@apache.org>
Authored: Mon Oct 17 16:05:17 2016 -0400
Committer: Di Li <d...@apache.org>
Committed: Mon Oct 17 16:05:17 2016 -0400

----------------------------------------------------------------------
 .../server/controller/internal/JsonHttpPropertyRequest.java    | 6 ++++--
 .../ambari/server/controller/internal/URLStreamProvider.java   | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fb6a7131/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/JsonHttpPropertyRequest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/JsonHttpPropertyRequest.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/JsonHttpPropertyRequest.java
index 6a93b4b..16a7ae7 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/JsonHttpPropertyRequest.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/JsonHttpPropertyRequest.java
@@ -62,7 +62,9 @@ public abstract class JsonHttpPropertyRequest extends 
HttpPropertyProvider.HttpP
 
     try {
       Map<String, Object> responseMap = 
GSON.fromJson(IOUtils.toString(inputStream, "UTF-8"), MAP_TYPE);
-
+      if (responseMap == null){
+        LOG.error("Properties map from HTTP response is null");
+      }
       for (Map.Entry<String, String> entry : getPropertyMappings().entrySet()) 
{
         Object propertyValueToSet = getPropertyValue(responseMap, 
entry.getKey());
         resource.setProperty(entry.getValue(), propertyValueToSet);
@@ -77,7 +79,7 @@ public abstract class JsonHttpPropertyRequest extends 
HttpPropertyProvider.HttpP
 
   // get the property value from the response map for the given property name
   private Object getPropertyValue(Map<String, Object> responseMap, String 
property) throws SystemException {
-    if (property == null) {
+    if (property == null || responseMap == null) {
       return null;
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fb6a7131/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
index c176ceb..501aa04 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
@@ -241,6 +241,9 @@ public class URLStreamProvider implements StreamProvider {
     } else {
         // not a 401 Unauthorized status code
         // we would let the original response propagate
+        if (statusCode == HttpStatus.SC_NOT_FOUND || statusCode == 
HttpStatus.SC_FORBIDDEN){
+          LOG.error(String.format("Received HTTP %s response from URL: %s", 
statusCode, spec));
+        }
         return connection;
     }
   }

Reply via email to