Skip to content

Commit

Permalink
Make sure we have Agroal datasources before configuring health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Oct 21, 2024
1 parent ac3c81c commit 33a1f0f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.agroal.api.AgroalDataSource;
import io.quarkus.agroal.runtime.AgroalDataSourceSupport;
import io.quarkus.agroal.runtime.AgroalDataSourceUtil;
import io.quarkus.arc.Arc;
import io.quarkus.datasource.common.runtime.DataSourceUtil;
import io.quarkus.datasource.runtime.DataSourceSupport;

Expand All @@ -32,19 +31,20 @@ public class DataSourceHealthCheck implements HealthCheck {
@Inject
Instance<DataSourceSupport> dataSourceSupport;

@Inject
Instance<AgroalDataSourceSupport> agroalDataSourceSupport;

private final Map<String, DataSource> checkedDataSources = new HashMap<>();

@PostConstruct
protected void init() {
if (!dataSourceSupport.isResolvable()) {
// No configured Agroal datasource at build time.
// No configured Agroal datasources at build time.
return;
}
DataSourceSupport support = dataSourceSupport.get();
AgroalDataSourceSupport agroalSupport = Arc.container().instance(AgroalDataSourceSupport.class)
.get();
Set<String> healthCheckExcludedNames = support.getHealthCheckExcludedNames();
for (String name : agroalSupport.entries.keySet()) {
for (String name : agroalDataSourceSupport.get().entries.keySet()) {
if (healthCheckExcludedNames.contains(name)) {
continue;
}
Expand Down

0 comments on commit 33a1f0f

Please sign in to comment.