slfan1989 commented on code in PR #5030:
URL: https://github.com/apache/hadoop/pull/5030#discussion_r999929985


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/AppsBlock.java:
##########
@@ -81,53 +154,53 @@ protected void render(Block html) {
 
     // Render the applications
     StringBuilder appsTableData = new StringBuilder("[\n");
-    for (AppInfo app : apps.getApps()) {
-      try {
-
-        String percent = String.format("%.1f", app.getProgress() * 100.0F);
-        String trackingURL =
-            app.getTrackingUrl() == null ? "#" : app.getTrackingUrl();
-        // AppID numerical value parsed by parseHadoopID in yarn.dt.plugins.js
-        appsTableData.append("[\"")
-            .append("<a href='").append(trackingURL).append("'>")
-            .append(app.getAppId()).append("</a>\",\"")
-            .append(escape(app.getUser())).append("\",\"")
-            .append(escape(app.getName())).append("\",\"")
-            .append(escape(app.getApplicationType())).append("\",\"")
-            .append(escape(app.getQueue())).append("\",\"")
-            .append(String.valueOf(app.getPriority())).append("\",\"")
-            .append(app.getStartTime()).append("\",\"")
-            .append(app.getFinishTime()).append("\",\"")
-            .append(app.getState()).append("\",\"")
-            .append(app.getFinalStatus()).append("\",\"")
-            // Progress bar
-            .append("<br title='").append(percent).append("'> <div class='")
-            .append(C_PROGRESSBAR).append("' title='")
-            .append(join(percent, '%')).append("'> ").append("<div class='")
-            .append(C_PROGRESSBAR_VALUE).append("' style='")
-            .append(join("width:", percent, '%')).append("'> </div> </div>")
-            // History link
-            .append("\",\"<a href='").append(trackingURL).append("'>")
-            .append("History").append("</a>");
-        appsTableData.append("\"],\n");
-
-      } catch (Exception e) {
-        LOG.info(
-            "Cannot add application {}: {}", app.getAppId(), e.getMessage());
+
+    if (appsInfo != null && CollectionUtils.isNotEmpty(appsInfo.getApps())) {
+      for (AppInfo app : appsInfo.getApps()) {
+        try {
+
+          String percent = String.format("%.1f", app.getProgress() * 100.0F);
+          String trackingURL =
+              app.getTrackingUrl() == null ? "#" : app.getTrackingUrl();
+
+          // AppID numerical value parsed by parseHadoopID in 
yarn.dt.plugins.js
+          appsTableData.append("[\"")
+              .append("<a href='").append(trackingURL).append("'>")
+              .append(app.getAppId()).append("</a>\",\"")
+              .append(escape(app.getUser())).append("\",\"")
+              .append(escape(app.getName())).append("\",\"")
+              .append(escape(app.getApplicationType())).append("\",\"")
+              .append(escape(app.getQueue())).append("\",\"")
+              .append(app.getPriority()).append("\",\"")
+              .append(app.getStartTime()).append("\",\"")
+              .append(app.getFinishTime()).append("\",\"")
+              .append(app.getState()).append("\",\"")
+              .append(app.getFinalStatus()).append("\",\"")
+              // Progress bar
+              .append("<br title='").append(percent).append("'> <div class='")
+              .append(C_PROGRESSBAR).append("' title='")
+              .append(join(percent, '%')).append("'> ").append("<div class='")
+              .append(C_PROGRESSBAR_VALUE).append("' style='")
+              .append(join("width:", percent, '%')).append("'> </div> </div>")
+              // History link
+              .append("\",\"<a href='").append(trackingURL).append("'>")
+              .append("History").append("</a>");
+          appsTableData.append("\"],\n");
+
+        } catch (Exception e) {
+          LOG.info(
+                  "Cannot add application {}: {}", app.getAppId(), 
e.getMessage());
+        }
+      }
+      if (appsTableData.charAt(appsTableData.length() - 2) == ',') {

Review Comment:
   I will modify the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to