jdbc-observations / datasource-micrometer

Micrometer Observation API instrumentation and Spring Boot 3 Auto-Configuration for JDBC APIs
Apache License 2.0
50 stars 8 forks source link

ExistingValue must be an instance of com.zaxxer.hikari.HikariDataSource #25

Closed cui086 closed 8 months ago

cui086 commented 8 months ago

Hey,

When I am trying to manually refresh the cloud config, I got java.lang.IllegalArgumentException: ExistingValue must be an instance of com.zaxxer.hikari.HikariDataSource

Is this error related to the datasource microment instrumentation? I saw similar issue happened in sleuth as in https://github.com/spring-cloud/spring-cloud-sleuth/issues/2096

Do you have a work around for this?


Caused by: java.lang.IllegalArgumentException: ExistingValue must be an instance of com.zaxxer.hikari.HikariDataSource
    at org.springframework.util.Assert.isTrue(Assert.java:140)
    at org.springframework.boot.context.properties.bind.Bindable.withExistingValue(Bindable.java:199)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBean.get(ConfigurationPropertiesBean.java:220)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:79)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:419)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1762)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:410)
    at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.rebind(ConfigurationPropertiesRebinder.java:138)
    at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.rebind(ConfigurationPropertiesRebinder.java:97)
    at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.rebind(ConfigurationPropertiesRebinder.java:85)
    at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.onApplicationEvent(ConfigurationPropertiesRebinder.java:170)
    at org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder.onApplicationEvent(ConfigurationPropertiesRebinder.java:53)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:174)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:145)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:445)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
    at org.springframework.cloud.context.refresh.ContextRefresher.refreshEnvironment(ContextRefresher.java:103)
    at org.springframework.cloud.context.refresh.ContextRefresher.refresh(ContextRefresher.java:94)
    at org.springframework.cloud.endpoint.RefreshEndpoint.refresh(RefreshEndpoint.java:41)```
cui086 commented 8 months ago

Resolved by: spring.cloud.refresh.never-refreshable=net.ttddyy.dsproxy.support.ProxyDataSource.

Please let me know if that does not make sense to you.

ttddyy commented 8 months ago

Based on the https://github.com/spring-cloud/spring-cloud-sleuth/issues/2096#issuecomment-1009070889, I think it is a reasonable solution.