Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 952ee58de -> da9669763


AMBARI-20207. Proper error is not thrown on hive view authorization page. 
(dipayanb)


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

Branch: refs/heads/branch-2.5
Commit: da9669763fd5225423f99bdd9364303009b1a8bb
Parents: 952ee58
Author: Dipayan Bhowmick <dipayan.bhowm...@gmail.com>
Authored: Wed Mar 1 12:05:03 2017 +0530
Committer: Dipayan Bhowmick <dipayan.bhowm...@gmail.com>
Committed: Wed Mar 1 12:05:03 2017 +0530

----------------------------------------------------------------------
 .../view/hive20/resources/system/ranger/RangerService.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/da966976/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
----------------------------------------------------------------------
diff --git 
a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
 
b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
index d300d9a..816d0e0 100644
--- 
a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
+++ 
b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
@@ -115,7 +115,13 @@ public class RangerService {
   }
 
   private List<Policy> parseResponse(String rangerResponse) {
-    JSONArray jsonArray = (JSONArray) JSONValue.parse(rangerResponse);
+    Object parsedResult = JSONValue.parse(rangerResponse);
+    if (parsedResult instanceof JSONObject) {
+      JSONObject obj = (JSONObject) parsedResult;
+      LOG.error("Bad response from Ranger: {}", rangerResponse);
+      throw new RangerException((String)obj.get("msgDesc"), "RANGER_ERROR", 
((Long)obj.get("statusCode")).intValue());
+    }
+    JSONArray jsonArray = (JSONArray) parsedResult;
     if (jsonArray.size() == 0) {
       return new ArrayList<>();
     }
@@ -184,6 +190,7 @@ public class RangerService {
         LOG.error("Ranger returned an empty stream.");
         throw new RangerException("Ranger returned an empty stream.", 
"RANGER_ERROR", 500);
       }
+
       return IOUtils.toString(stream);
     } catch (IOException e) {
       LOG.error("Bad response from Ranger. Exception: {}", e);

Reply via email to