DaanHoogland commented on a change in pull request #4144:
URL: https://github.com/apache/cloudstack/pull/4144#discussion_r465524355
##########
File path: usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
##########
@@ -275,7 +277,16 @@ public boolean configure(String name, Map<String, Object>
params) throws Configu
s_logger.error("Unhandled exception configuring UsageManger", e);
throw new ConfigurationException("Unhandled exception configuring
UsageManager " + e.toString());
}
- _pid = Integer.parseInt(System.getProperty("pid"));
+
+ String processName = null;
+ try {
+ processName = ManagementFactory.getRuntimeMXBean().getName();
+ _pid = Integer.parseInt(processName.split("@")[0]);
+ } catch (Exception e) {
+ String msg = String.format("Unable to get process Id for %s!",
processName);
+ s_logger.debug(msg , e);
+ throw new ConfigurationException(msg + " " + e.toString());
Review comment:
`logger.debug(msg, e)` should log the entire stacktrace @GabrielBrascher
. and it gives the user to filter or direct the output to a certain
stream/file. `e.printStacktrace()` only logs to stdout (or stderr, i forgot).
in short i think not too much of it. I agree toString does not seem the best,
but we have alreadyt output the stacktrace by then. A change from `toString()`
to `getLocalizedMessage()` maybe, @div8cn? Of course we can add the entire
exception again i.e. `throw new ConfigurationException(msg, e)`, that's fine as
well.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]