Mercurial > hg > release > thermostat-2.0
changeset 1575:91e6e6bc3be9
Prevent NPE when checking for VmInfo isAlive status
Reviewed-by: omajid, jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-November/011838.html
author | Jie Kang <jkang@redhat.com> |
---|---|
date | Fri, 28 Nov 2014 13:48:29 -0500 |
parents | 967ff19b0416 |
children | a614e6dec69a |
files | client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ListVMsCommand.java client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/LocaleResources.java client/cli/src/main/resources/com/redhat/thermostat/client/cli/strings.properties |
diffstat | 3 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ListVMsCommand.java Fri Nov 28 12:04:09 2014 +0100 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ListVMsCommand.java Fri Nov 28 13:48:29 2014 -0500 @@ -89,10 +89,14 @@ formatter.addHeader(); for (HostRef host : hosts) { AgentInformation agentInfo = agentInfoDAO.getAgentInformation(host); - Collection<VmRef> vms = vmsDAO.getVMs(host); - for (VmRef vm : vms) { - VmInfo info = vmsDAO.getVmInfo(vm); - formatter.addVM(vm, agentInfo, info); + if (agentInfo != null) { + Collection<VmRef> vms = vmsDAO.getVMs(host); + for (VmRef vm : vms) { + VmInfo info = vmsDAO.getVmInfo(vm); + formatter.addVM(vm, agentInfo, info); + } + } else { + ctx.getConsole().getError().println(translator.localize(LocaleResources.ENCOUNTERED_NULL_AGENT, host.getName())); } } formatter.format(ctx.getConsole().getOutput());
--- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/LocaleResources.java Fri Nov 28 12:04:09 2014 +0100 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/LocaleResources.java Fri Nov 28 13:48:29 2014 -0500 @@ -115,6 +115,8 @@ AFFIRMATIVE_RESPONSES, VM_STAT_INVALID_SINCE_ARGUMENT, + + ENCOUNTERED_NULL_AGENT, ; static final String RESOURCE_BUNDLE = "com.redhat.thermostat.client.cli.strings";
--- a/client/cli/src/main/resources/com/redhat/thermostat/client/cli/strings.properties Fri Nov 28 12:04:09 2014 +0100 +++ b/client/cli/src/main/resources/com/redhat/thermostat/client/cli/strings.properties Fri Nov 28 13:48:29 2014 -0500 @@ -73,4 +73,6 @@ PURGE_CANCELLED_MESSAGE = Not cleaning Thermostat data at this time. AFFIRMATIVE_RESPONSES = y|yes VM_STAT_INVALID_SINCE_ARGUMENT = Invalid arguments for -since : Expected format time:timeunit : e.g. 5:seconds. Time must be positive. \ - Timeunit must be days, hours, minutes or seconds. \ No newline at end of file + Timeunit must be days, hours, minutes or seconds. + +ENCOUNTERED_NULL_AGENT = Warning: Could not find agent information for: {0} Storage has inconsistent data \ No newline at end of file