ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [35/50] [abbrv] ambari git commit: AMBARI-18588 Ambari server should not crash with NPE when parsing HTTP response for YARN RM properties (dili)
Date Wed, 19 Oct 2016 16:47:46 GMT
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/73f1dea9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/73f1dea9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/73f1dea9

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 73f1dea9674359ecbfd723917c83913b20986906
Parents: 41c49e1
Author: Di Li <dili@apache.org>
Authored: Mon Oct 17 10:35:25 2016 -0400
Committer: Di Li <dili@apache.org>
Committed: Mon Oct 17 10:35:25 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/73f1dea9/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/73f1dea9/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;
     }
   }


Mime
View raw message