
Description
In our application (Spring Boot 2.5.2) we are trying to use com.amazonaws.xray.sql.TracingDataSource
as the primary DataSource
; it's essentially a wrapper around a regular data source to enable AWS X-Ray metrics.
During startup, the application tries to create a derived DataSource
from it (DataSourceBuilder.derivedFrom(dataSource)
, the Liquibase starter is doing this).
The TracingDataSource
is not recognized as a source for MappedDataSourceProperties
, so we end up with a ReflectionDataSourceProperties
, trying to to find the getters for the properties by reflection. However, it is erroneously looking for getter methods with one String
parameter (DataSourceProperty:293-294)
. Even if such getters were to exist, they are later on (ReflectionDataSourceProperties:553
) called with no parameters, resulting in an IllegalArgumentException
anyway.
Example configuration to trigger the issue:
@Bean(name = "dataSource")
@Primary
public DataSource tracingDataSource(HikariDataSource dataSource) {
return new TracingDataSource(dataSource) {
public String getUrl() {
return ((HikariDataSource) delegate).getJdbcUrl();
}
...
};
}
@Bean
public HikariDataSource hikariDataSource(DataSourceProperties properties) {
HikariDataSource dataSource =
properties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
if (StringUtils.hasText(properties.getName())) {
dataSource.setPoolName(properties.getName());
}
return dataSource;
}
@Bean
public DataSource derived(@Qualifier("dataSource") DataSource dataSource) {
DataSourceBuilder<?> builder =
DataSourceBuilder.derivedFrom(dataSource).type(SimpleDriverDataSource.class);
return builder.build(); // UnsupportedDataSourcePropertyException: Unable to find suitable method for url
}