Skip to content

Commit 63c5b01

Browse files
Simon B. Laursenfhussonnois
authored andcommitted
fix(aiven) healthcheck DOWN when project not set
1 parent a833a5d commit 63c5b01

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

providers/jikkou-provider-aiven/src/main/java/io/streamthoughts/jikkou/extension/aiven/health/AivenServiceHealthIndicator.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ public void init(@NotNull AivenApiClientConfig apiClientConfig) throws ConfigExc
6363
*/
6464
@Override
6565
public Health getHealth(final Duration timeout) {
66-
if (apiClientConfig == null) {
67-
throw new IllegalStateException("must be configured!");
66+
if (apiClientConfig == null || apiClientConfig.project() == null) {
67+
return Health
68+
.builder()
69+
.name(HEALTH_NAME)
70+
.unknown()
71+
.build();
6872
}
69-
final AivenApiClient api = AivenApiClientFactory.create(apiClientConfig);
70-
try {
73+
try (AivenApiClient api = AivenApiClientFactory.create(apiClientConfig)) {
7174
ServiceInformationResponse response = api.getServiceInformation();
7275
if (!response.errors().isEmpty()) {
7376
return new Health.Builder()
@@ -117,8 +120,6 @@ public Health getHealth(final Duration timeout) {
117120
.details("resource", getUrn())
118121
.details(Map.of("message", "An unexpected error has occurred while retrieving the information."))
119122
.build();
120-
} finally {
121-
api.close(); // make sure api is closed after catching exception
122123
}
123124
}
124125

0 commit comments

Comments
 (0)