Skip to content

Commit 7f605ff

Browse files
committed
Make methods in StatusUpdater protected.
For easier cusotmization. E.g. converting some of the data fechted from the /info endpoint or to filter it.
1 parent ab1079f commit 7f605ff

File tree

1 file changed

+13
-5
lines changed
  • spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry

1 file changed

+13
-5
lines changed

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/registry/StatusUpdater.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,31 @@ public void updateStatus(Application application) {
8080
}
8181
}
8282

83-
private Info queryInfo(Application application) {
83+
protected Info queryInfo(Application application) {
8484
try {
8585
ResponseEntity<Map<String, Serializable>> response = applicationOps
8686
.getInfo(application);
8787
if (response.getStatusCode().is2xxSuccessful() && response.hasBody()) {
88-
return Info.from(response.getBody());
88+
return convertInfo(response);
8989
} else {
9090
LOGGER.info("Couldn't retrieve info for {}: {} - {}", application,
9191
response.getStatusCode(), response.getBody());
9292
return Info.empty();
9393
}
9494
} catch (Exception ex) {
9595
LOGGER.warn("Couldn't retrieve info for {}", application, ex);
96-
return Info.empty();
96+
return convertInfo(ex);
9797
}
9898
}
9999

100+
protected Info convertInfo(ResponseEntity<Map<String, Serializable>> response) {
101+
return Info.from(response.getBody());
102+
}
103+
104+
protected Info convertInfo(Exception ex) {
105+
return Info.empty();
106+
}
107+
100108
protected StatusInfo queryStatus(Application application) {
101109
LOGGER.trace("Updating status for {}", application);
102110
try {
@@ -111,7 +119,7 @@ protected StatusInfo queryStatus(Application application) {
111119
}
112120
}
113121

114-
private StatusInfo convertStatusInfo(ResponseEntity<Map<String, Serializable>> response) {
122+
protected StatusInfo convertStatusInfo(ResponseEntity<Map<String, Serializable>> response) {
115123
if (response.hasBody() && response.getBody().get("status") instanceof String) {
116124
return StatusInfo.valueOf((String) response.getBody().get("status"),
117125
response.getBody());
@@ -128,7 +136,7 @@ private StatusInfo convertStatusInfo(ResponseEntity<Map<String, Serializable>> r
128136
return StatusInfo.ofDown(details);
129137
}
130138

131-
private StatusInfo convertStatusInfo(Exception ex) {
139+
protected StatusInfo convertStatusInfo(Exception ex) {
132140
Map<String, Serializable> details = new HashMap<>();
133141
details.put("message", ex.getMessage());
134142
details.put("exception", ex.getClass().getName());

0 commit comments

Comments
 (0)