2222import org .springframework .context .ApplicationEventPublisher ;
2323import org .springframework .context .ApplicationEventPublisherAware ;
2424import org .springframework .http .ResponseEntity ;
25- import org .springframework .web .client .RestClientException ;
2625import org .springframework .web .client .RestTemplate ;
2726
2827import de .codecentric .boot .admin .event .ClientApplicationStatusChangedEvent ;
3433 * The StatusUpdater is responsible for updatig the status of all or a single application querying
3534 * the healthUrl.
3635 *
37- * @author Johannes Stelzer
36+ * @author Johannes Edmeier
3837 */
3938public class StatusUpdater implements ApplicationEventPublisherAware {
4039 private static final Logger LOGGER = LoggerFactory .getLogger (StatusUpdater .class );
@@ -70,8 +69,8 @@ public void updateStatus(Application application) {
7069 store .save (newState );
7170
7271 if (!newStatus .equals (oldStatus )) {
73- publisher .publishEvent (new ClientApplicationStatusChangedEvent ( newState , oldStatus ,
74- newStatus ));
72+ publisher .publishEvent (
73+ new ClientApplicationStatusChangedEvent ( newState , oldStatus , newStatus ));
7574 }
7675 }
7776
@@ -80,19 +79,19 @@ private StatusInfo queryStatus(Application application) {
8079
8180 try {
8281 @ SuppressWarnings ("unchecked" )
83- ResponseEntity <Map <String , String >> response = restTemplate .getForEntity (
84- application .getHealthUrl (), (Class <Map <String , String >>) (Class <?>) Map .class );
82+ ResponseEntity <Map <String , Object >> response = restTemplate .getForEntity (
83+ application .getHealthUrl (), (Class <Map <String , Object >>) (Class <?>) Map .class );
8584 LOGGER .debug ("/health for {} responded with {}" , application , response );
8685
87- if (response .hasBody () && response .getBody ().get ("status" ) != null ) {
88- return StatusInfo .valueOf (response .getBody ().get ("status" ));
86+ if (response .hasBody () && response .getBody ().get ("status" ) instanceof String ) {
87+ return StatusInfo .valueOf (( String ) response .getBody ().get ("status" ));
8988 } else if (response .getStatusCode ().is2xxSuccessful ()) {
9089 return StatusInfo .ofUp ();
9190 } else {
9291 return StatusInfo .ofDown ();
9392 }
9493
95- } catch (RestClientException ex ) {
94+ } catch (Exception ex ) {
9695 LOGGER .warn ("Couldn't retrieve status for {}" , application , ex );
9796 return StatusInfo .ofOffline ();
9897 }
0 commit comments