@@ -45,19 +45,20 @@ public class RefreshScopeHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Builder builder) throws Exception {
|
||||
Map<String, Exception> errors = new HashMap<>(this.scope.getIfAvailable().getErrors());
|
||||
errors.putAll(this.rebinder.getErrors());
|
||||
if (errors.isEmpty()) {
|
||||
builder.up();
|
||||
}
|
||||
else {
|
||||
builder.down();
|
||||
if (errors.size() == 1) {
|
||||
builder.withException(errors.values().iterator().next());
|
||||
}
|
||||
else {
|
||||
for (String name : errors.keySet()) {
|
||||
builder.withDetail(name, errors.get(name));
|
||||
RefreshScope refreshScope = this.scope.getIfAvailable();
|
||||
if(refreshScope != null) {
|
||||
Map<String, Exception> errors = new HashMap<>(refreshScope.getErrors());
|
||||
errors.putAll(this.rebinder.getErrors());
|
||||
if (errors.isEmpty()) {
|
||||
builder.up();
|
||||
} else {
|
||||
builder.down();
|
||||
if (errors.size() == 1) {
|
||||
builder.withException(errors.values().iterator().next());
|
||||
} else {
|
||||
for (String name : errors.keySet()) {
|
||||
builder.withDetail(name, errors.get(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,11 @@ public class RefreshScopeHealthIndicatorTests {
|
||||
assertEquals(Status.DOWN, this.indicator.health().getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullRefreshScope() {
|
||||
ObjectProvider<RefreshScope> scopeProvider = mock(ObjectProvider.class);
|
||||
BDDMockito.willReturn(null).given(scopeProvider).getIfAvailable();
|
||||
assertEquals(Status.UP, this.indicator.health().getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user