When Spring Boot autoconfiguration instantiates io.r2dbc.spi.ConnectionFactory bean implementing io.r2dbc.spi.Closeable, the framework should have a custom destruction method invoke Closeable.close() and subscribe to the returned Publisher.
If a user application creates its own ConnectionFactory, it would be the user's responsibility to then close it. Although it might be nice to have a generic pre-destruction facility that looks for all R2DBC Closeable beans and closes them cleanly. The regular Spring bean destruction mechanism won't work here, since Spring Framework would call .close() but not subscribe to it, making it a no-op.
cc: @mp911de
When Spring Boot autoconfiguration instantiates
io.r2dbc.spi.ConnectionFactorybean implementingio.r2dbc.spi.Closeable, the framework should have a custom destruction method invokeCloseable.close()and subscribe to the returnedPublisher.If a user application creates its own
ConnectionFactory, it would be the user's responsibility to then close it. Although it might be nice to have a generic pre-destruction facility that looks for all R2DBCCloseablebeans and closes them cleanly. The regular Spring bean destruction mechanism won't work here, since Spring Framework would call.close()but not subscribe to it, making it a no-op.cc: @mp911de