Skip to content

jdbc.connections.active and jdbc.connections.idle metrics are not available when using Hikari in a native image #46214

Closed
@sdeleuze

Description

@sdeleuze

When building https://github.com/spring-projects/spring-petclinic with Spring Boot 4.0.0-SNAPSHOT, I get the following error:

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively read or write field

   private volatile com.zaxxer.hikari.pool.HikariPool com.zaxxer.hikari.HikariDataSource.pool

This reflective operation seems to be done via DataSourcePoolMetricsAutoConfiguration$DataSourcePoolMetadataMetricsConfiguration$DataSourcePoolMetadataMeterBinder.bindTo -> MeterRegistryPostProcessor.lambda$applyBinders. In DataSourceBuilderRuntimeHints I see a reflective hint for HikariDataSource but not for its pool field.

It works fine with Spring Boot 3.5.3 or Spring Boot 4.0.0-SNAPSHOT with a RuntimeHintsRegistrar performing hints.reflection().registerType(HikariDataSource.class, builder -> builder.withField("pool"));, so maybe Spring Boot 4 should add this reflective hint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions