The code implies resource could be null, and yet de-references resource before the null check. As I was experiencing a NPE because if this exact scenario, put the remote agent check inside the check for null to avoid problems. If resource is null we log that we were unable to send ping due to agent disconnected...

This commit is contained in:
Kris McQueen 2010-10-14 14:38:08 -07:00
parent 2185adc086
commit e168760295
1 changed files with 5 additions and 5 deletions

View File

@ -125,11 +125,11 @@ public class DirectAgentAttache extends AgentAttache {
try {
ServerResource resource = _resource;
if (resource.IsRemoteAgent()) {
return;
}
if (resource != null) {
if (resource != null) {
if (resource.IsRemoteAgent()) {
return;
}
PingCommand cmd = resource.getCurrentStatus(_id);
if (cmd == null) {
s_logger.warn("Unable to get current status on " + _id);