@@ -1052,12 +1052,24 @@ public boolean stop() {
10521052 }
10531053
10541054 if (_mshostId != null ) {
1055- final ManagementServerHostVO mshost = _mshostDao .findByMsid (_msId );
1056- final ManagementServerStatusVO mshostStatus = mshostStatusDao .findByMsId (mshost .getUuid ());
1057- mshost .setState (ManagementServerHost .State .Down );
1058- mshostStatus .setLastJvmStop (new Date ());
1059- _mshostDao .update (_mshostId , mshost );
1060- mshostStatusDao .update (mshostStatus .getId (), mshostStatus );
1055+ ManagementServerHostVO mshost = _mshostDao .findByMsid (_msId );
1056+ if (mshost != null ) {
1057+ ManagementServerStatusVO mshostStatus = mshostStatusDao .findByMsId (mshost .getUuid ());
1058+ if (mshostStatus != null ) {
1059+ mshost .setState (ManagementServerHost .State .Down );
1060+ mshostStatus .setLastJvmStop (new Date ());
1061+ _mshostDao .update (_mshostId , mshost );
1062+ mshostStatusDao .update (mshostStatus .getId (), mshostStatus );
1063+ } else {
1064+ s_logger .warn (String .format ("Found a management server host [%s] without a status. This should never happen!" , mshost ));
1065+ mshostStatus = new ManagementServerStatusVO ();
1066+ mshostStatus .setMsId (mshost .getUuid ());
1067+ mshostStatus .setLastSystemBoot (new Date ());
1068+ mshostStatus .setLastJvmStart (new Date ());
1069+ mshostStatus .setUpdated (new Date ());
1070+ mshostStatusDao .persist (mshostStatus );
1071+ }
1072+ }
10611073 }
10621074
10631075 _heartbeatScheduler .shutdownNow ();
0 commit comments