Commit b0406450 by Johannes Edmeier

Merge branch '1.2.x'

parents 215f2a1d 6967ddd5
......@@ -22,7 +22,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent;
......@@ -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 healthUrl.
*
* @author Johannes Stelzer
* @author Johannes Edmeier
*/
public class StatusUpdater implements ApplicationEventPublisherAware {
private static final Logger LOGGER = LoggerFactory.getLogger(StatusUpdater.class);
......@@ -70,8 +69,8 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
store.save(newState);
if (!newStatus.equals(oldStatus)) {
publisher.publishEvent(new ClientApplicationStatusChangedEvent(newState, oldStatus,
newStatus));
publisher.publishEvent(
new ClientApplicationStatusChangedEvent(newState, oldStatus, newStatus));
}
}
......@@ -80,19 +79,19 @@ public class StatusUpdater implements ApplicationEventPublisherAware {
try {
@SuppressWarnings("unchecked")
ResponseEntity<Map<String, String>> response = restTemplate.getForEntity(
application.getHealthUrl(), (Class<Map<String, String>>) (Class<?>) Map.class);
ResponseEntity<Map<String, Object>> response = restTemplate.getForEntity(
application.getHealthUrl(), (Class<Map<String, Object>>) (Class<?>) Map.class);
LOGGER.debug("/health for {} responded with {}", application, response);
if (response.hasBody() && response.getBody().get("status") != null) {
return StatusInfo.valueOf(response.getBody().get("status"));
if (response.hasBody() && response.getBody().get("status") instanceof String) {
return StatusInfo.valueOf((String) response.getBody().get("status"));
} else if (response.getStatusCode().is2xxSuccessful()) {
return StatusInfo.ofUp();
} else {
return StatusInfo.ofDown();
}
} catch (RestClientException ex) {
} catch (Exception ex) {
LOGGER.warn("Couldn't retrieve status for {}", application, ex);
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