Fix StatusAggregator static initialization
Prior to this commit, there was a cycle between `StatusAggregator` and `SimpleStatusAggregator`, which caused a static initialization bug - depending on which class (the implementation or its interface) was loaded first. This commit turns the static field of the `StatusAggregator` interface into a static method to avoid this problem. Fixes gh-21211
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class SimpleStatusAggregatorTests {
|
||||
|
||||
@Test
|
||||
void getAggregateStatusWhenUsingDefaultOrder() {
|
||||
void getAggregateStatusWhenUsingDefaultInstance() {
|
||||
StatusAggregator aggregator = StatusAggregator.getDefault();
|
||||
Status status = aggregator.getAggregateStatus(Status.DOWN, Status.UP, Status.UNKNOWN, Status.OUT_OF_SERVICE);
|
||||
assertThat(status).isEqualTo(Status.DOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAggregateStatusWhenUsingNewDefaultOrder() {
|
||||
SimpleStatusAggregator aggregator = new SimpleStatusAggregator();
|
||||
Status status = aggregator.getAggregateStatus(Status.DOWN, Status.UP, Status.UNKNOWN, Status.OUT_OF_SERVICE);
|
||||
assertThat(status).isEqualTo(Status.DOWN);
|
||||
|
||||
Reference in New Issue
Block a user