mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '3.5.x'
Closes gh-48487
This commit is contained in:
+1
-1
@@ -52,7 +52,7 @@ public class RabbitHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
private @Nullable String getVersion() {
|
||||
return this.rabbitTemplate.execute((channel) -> {
|
||||
Object version = channel.getConnection().getServerProperties().get("version");
|
||||
Object version = channel.getConnection().getServerProperties().getOrDefault("version", "unknown");
|
||||
Assert.state(version != null, "'version' must not be null");
|
||||
return version.toString();
|
||||
});
|
||||
|
||||
+11
@@ -70,6 +70,17 @@ class RabbitHealthIndicatorTests {
|
||||
assertThat(health.getDetails()).containsEntry("version", "123");
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenVersionIsMissingShouldReturnUpWithUnknownVersion() {
|
||||
givenTemplateExecutionWillInvokeCallback();
|
||||
Connection connection = mock(Connection.class);
|
||||
given(this.channel.getConnection()).willReturn(connection);
|
||||
given(connection.getServerProperties()).willReturn(Collections.emptyMap());
|
||||
Health health = new RabbitHealthIndicator(this.rabbitTemplate).health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails()).containsEntry("version", "unknown");
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenConnectionFailsShouldReturnDown() {
|
||||
givenTemplateExecutionWillInvokeCallback();
|
||||
|
||||
Reference in New Issue
Block a user