gavlyukovskiy/spring-boot-data-source-decorator

Optional decoration of AbstractRoutingDataSource

oburgosm opened this issue · 4 comments

I have and application which uses data-source-proxy, AbstracttRoutingDataSource and actuator health check. Since I updated to version 1.8.0 actuator health check is not working, because the decorated datasource is not and instance of AbstractRoutingDataSource. For this reason I think it would be very interesting that data-source-decorator had a property to enable/disable decorators for AbstractRoutingDataSource. It would be something similar to this

@oburgosm thank you for bringing this up and useful context from similar problem in spring boot issue, and thank you for creating a PR. Looking at #72 I think we should automatically decorate underlying data sources (using AbstractRoutingDataSource#getResolvedDataSources) and it looks like in spring boot they did just that with health indicators spring-projects/spring-boot#25708.

What do you think about this approach? The only tricky part is that those data sources might also be beans, so we need to make sure not to decorate them twice, but that should be an easy check. Also it might be a breaking change for some advanced scenarios, so I would still do it behind a property (and maybe do that by default in 1.9.0).

In my case, the underlying datasources are also beans, and them they are decorated , so I don't have a need to decorate them from the routing datasource. But I understand that this approach could be useful in other scenarios and then, it'd be very important to check that the underlying datasources are not decorated twice.

@oburgosm I looked more deep at the code and I was wrong - it's not possible to decorate data sources after they were resolved and there is no way to get target data sources before resolution.

Released in 1.8.1. Thank you for the contribution!