diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java index b8119e5ec2..1de4cd1724 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java @@ -426,8 +426,17 @@ private List getContainerLogFiles( if (response.getStatusInfo().getStatusCode() == ClientResponse.Status.OK.getStatusCode()) { try { + JSONArray array = new JSONArray(); JSONObject json = response.getEntity(JSONObject.class); - JSONArray array = json.getJSONArray("containerLogsInfo"); + Object logsInfoObj = json.get("containerLogsInfo"); + if (logsInfoObj instanceof JSONObject) { + array.put((JSONObject)logsInfoObj); + } else if (logsInfoObj instanceof JSONArray) { + JSONArray logsArray = (JSONArray)logsInfoObj; + for (int i=0; i < logsArray.length(); i++) { + array.put(logsArray.getJSONObject(i)); + } + } for (int i = 0; i < array.length(); i++) { JSONObject log = array.getJSONObject(i); Object ob = log.get("containerLogInfo");