@@ -582,6 +582,11 @@ private AgentControlAnswer handleControlCommand(final AgentAttache attache, fina
582582
583583 private AgentConnectStatusAnswer handleAgentConnectStatusCommand (AgentAttache attache , AgentConnectStatusCommand cmd ) {
584584 HostVO hostVo = _hostDao .findById (attache .getId ());
585+ if (hostVo == null ) {
586+ String details = String .format ("Unable to find Host in DB with id %s for AgentConnectStatusCommand hostId=%s guid=%s name=%s" ,
587+ attache .getId (), cmd .getHostId (), cmd .getHostGuid (), cmd .getHostName ());
588+ return new AgentConnectStatusAnswer (cmd , false , details );
589+ }
585590 return getConnectStatusAnswer (hostVo , cmd );
586591 }
587592
@@ -592,7 +597,7 @@ private AgentConnectStatusAnswer getConnectStatusAnswer(HostVO hostVo, AgentConn
592597 Status status = hostVo .getStatus ();
593598 try {
594599 boolean lockAvailable = GlobalLock .isLockAvailable (lockName );
595- String details = String .format ("Global lock %s is%s present for %s" , lockName , lockAvailable ? "" : " not" ,
600+ String details = String .format ("Global lock %s is %s present for %s" , lockName , lockAvailable ? "" : " not" ,
596601 hostName );
597602 logger .debug (details );
598603 return getAgentConnectStatusAnswer (cmd , lockName , hostName , lockAvailable , status , details );
@@ -612,7 +617,7 @@ private AgentConnectStatusAnswer getAgentConnectStatusAnswer(AgentConnectStatusC
612617 boolean lockAvailable ,
613618 Status status ,
614619 String details ) {
615- logger .debug (String . format ( "Checking whether global lock %s is present for %s " , lockName , hostName ) );
620+ logger .debug ("Checking whether global lock {} is present for {} " , lockName , hostName );
616621 AgentConnectStatusAnswer answer = new AgentConnectStatusAnswer (cmd , true , details );
617622 answer .setLockAvailable (lockAvailable );
618623 answer .setHostStatus (status );
@@ -2024,7 +2029,7 @@ protected void connectAgent(final Link link, final Command[] cmds, final Request
20242029 answers [i ] = answer ;
20252030 }
20262031 }
2027- Response response = new Response (request , answers , _nodeId , -1 );
2032+ Response response = new Response (request , answers [ 0 ] , _nodeId , -1 );
20282033 try {
20292034 link .send (response .toBytes ());
20302035 } catch (ClosedChannelException e ) {
0 commit comments