Commit b0406450 by Johannes Edmeier

Merge branch '1.2.x'

parents 215f2a1d 6967ddd5
...@@ -22,7 +22,6 @@ import org.slf4j.LoggerFactory; ...@@ -22,7 +22,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent; import de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent;
...@@ -34,7 +33,7 @@ import de.codecentric.boot.admin.registry.store.ApplicationStore; ...@@ -34,7 +33,7 @@ import de.codecentric.boot.admin.registry.store.ApplicationStore;
* The StatusUpdater is responsible for updatig the status of all or a single application querying * The StatusUpdater is responsible for updatig the status of all or a single application querying
* the healthUrl. * the healthUrl.
* *
* @author Johannes Stelzer * @author Johannes Edmeier
*/ */
public class StatusUpdater implements ApplicationEventPublisherAware { public class StatusUpdater implements ApplicationEventPublisherAware {
private static final Logger LOGGER = LoggerFactory.getLogger(StatusUpdater.class); private static final Logger LOGGER = LoggerFactory.getLogger(StatusUpdater.class);
...@@ -70,8 +69,8 @@ public class StatusUpdater implements ApplicationEventPublisherAware { ...@@ -70,8 +69,8 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
store.save(newState); store.save(newState);
if (!newStatus.equals(oldStatus)) { if (!newStatus.equals(oldStatus)) {
publisher.publishEvent(new ClientApplicationStatusChangedEvent(newState, oldStatus, publisher.publishEvent(
newStatus)); new ClientApplicationStatusChangedEvent(newState, oldStatus, newStatus));
} }
} }
...@@ -80,19 +79,19 @@ public class StatusUpdater implements ApplicationEventPublisherAware { ...@@ -80,19 +79,19 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ResponseEntity<Map<String, String>> response = restTemplate.getForEntity( ResponseEntity<Map<String, Object>> response = restTemplate.getForEntity(
application.getHealthUrl(), (Class<Map<String, String>>) (Class<?>) Map.class); application.getHealthUrl(), (Class<Map<String, Object>>) (Class<?>) Map.class);
LOGGER.debug("/health for {} responded with {}", application, response); LOGGER.debug("/health for {} responded with {}", application, response);
if (response.hasBody() && response.getBody().get("status") != null) { if (response.hasBody() && response.getBody().get("status") instanceof String) {
return StatusInfo.valueOf(response.getBody().get("status")); return StatusInfo.valueOf((String) response.getBody().get("status"));
} else if (response.getStatusCode().is2xxSuccessful()) { } else if (response.getStatusCode().is2xxSuccessful()) {
return StatusInfo.ofUp(); return StatusInfo.ofUp();
} else { } else {
return StatusInfo.ofDown(); return StatusInfo.ofDown();
} }
} catch (RestClientException ex) { } catch (Exception ex) {
LOGGER.warn("Couldn't retrieve status for {}", application, ex); LOGGER.warn("Couldn't retrieve status for {}", application, ex);
return StatusInfo.ofOffline(); return StatusInfo.ofOffline();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment