From 21ce2dd324300e852bc6063f5a4625c54b88fb2c Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Tue, 14 May 2019 17:09:14 +0800 Subject: [PATCH] dashboard command remove the useless tomcat table. #696 --- .../core/command/monitor200/DashboardCommand.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/DashboardCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/DashboardCommand.java index a826e0943..70e3fd9e2 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/DashboardCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/DashboardCommand.java @@ -296,7 +296,7 @@ public class DashboardCommand extends AnnotatedCommand { } String drawRuntimeInfoAndTomcatInfo(int width, int height) { - TableElement table = new TableElement(1, 1); + TableElement resultTable = new TableElement(1, 1); TableElement runtimeInfoTable = new TableElement(1, 1).rightCellPadding(1); runtimeInfoTable @@ -304,11 +304,12 @@ public class DashboardCommand extends AnnotatedCommand { addRuntimeInfo(runtimeInfoTable); - TableElement tomcatInfoTable = new TableElement(1, 1).rightCellPadding(1); + TableElement tomcatInfoTable = null; try { // 如果请求tomcat信息失败,则不显示tomcat信息 if (NetUtils.request("http://localhost:8006").isSuccess()) { + tomcatInfoTable = new TableElement(1, 1).rightCellPadding(1); tomcatInfoTable .add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("Tomcat", "")); addTomcatInfo(tomcatInfoTable); @@ -317,8 +318,13 @@ public class DashboardCommand extends AnnotatedCommand { logger.error(null, "get Tomcat Info error!", t); } - table.row(runtimeInfoTable, tomcatInfoTable); - return RenderUtil.render(table, width, height); + if (tomcatInfoTable != null) { + resultTable.row(runtimeInfoTable, tomcatInfoTable); + } else { + resultTable = runtimeInfoTable; + } + + return RenderUtil.render(resultTable, width, height); } static class MemoryEntry {