提交 d475e36e 编写于 作者: S shshahma

8177721: Improve diagnostics in sun.management.Agent#startAgent()

Reviewed-by: dfuchs, dholmes
上级 eee56c49
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -211,7 +211,7 @@ public class Agent { ...@@ -211,7 +211,7 @@ public class Agent {
throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified"); throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
} }
} catch (AgentConfigurationError err) { } catch (AgentConfigurationError err) {
error(err.getError(), err.getParams()); error(err);
} }
} }
...@@ -266,7 +266,7 @@ public class Agent { ...@@ -266,7 +266,7 @@ public class Agent {
} }
} catch (AgentConfigurationError e) { } catch (AgentConfigurationError e) {
error(e.getError(), e.getParams()); error(e);
} catch (Exception e) { } catch (Exception e) {
error(e); error(e);
} }
...@@ -496,18 +496,6 @@ public class Agent { ...@@ -496,18 +496,6 @@ public class Agent {
throw new RuntimeException(keyText); throw new RuntimeException(keyText);
} }
public static void error(String key, String[] params) {
if (params == null || params.length == 0) {
error(key);
} else {
StringBuffer message = new StringBuffer(params[0]);
for (int i = 1; i < params.length; i++) {
message.append(" " + params[i]);
}
error(key, message.toString());
}
}
public static void error(String key, String message) { public static void error(String key, String message) {
String keyText = getText(key); String keyText = getText(key);
System.err.print(getText("agent.err.error") + ": " + keyText); System.err.print(getText("agent.err.error") + ": " + keyText);
...@@ -521,6 +509,23 @@ public class Agent { ...@@ -521,6 +509,23 @@ public class Agent {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
public static void error(AgentConfigurationError e) {
String keyText = getText(e.getError());
String[] params = e.getParams();
System.err.print(getText("agent.err.error") + ": " + keyText);
if (params != null && params.length != 0) {
StringBuffer message = new StringBuffer(params[0]);
for (int i = 1; i < params.length; i++) {
message.append(" " + params[i]);
}
System.err.println(": " + message);
}
e.printStackTrace();
throw new RuntimeException(e);
}
public static void warning(String key, String message) { public static void warning(String key, String message) {
System.err.print(getText("agent.err.warning") + ": " + getText(key)); System.err.print(getText("agent.err.warning") + ": " + getText(key));
System.err.println(": " + message); System.err.println(": " + message);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册