spring-projects / spring-data-r2dbc

Provide support to increase developer productivity in Java when using Reactive Relational Database Connectivity. Uses familiar Spring concepts such as a DatabaseClient for core API usage and lightweight repository style data access.
Apache License 2.0
708 stars 132 forks source link

ConditionalGenericConverter is not properly handled by Spring Data R2DBC #852

Closed Paramood closed 7 months ago

Paramood commented 7 months ago

Actual behavior:

If getConvertibleTypes method returns null, the converter is ignored at all.

Expected behavior:

If getConvertibleTypes method returns null, then matches method must be used instead for the converter. This is how it works in Spring if using ConditionalGenericConverter for controller layer and this is what the doc says.

From javadoc of getConvertibleTypes method:

For conditional converters this method may return null to indicate all source-to-target pairs should be considered.

Sample project with tests to reproduce the issue: r2dbc-sample.zip

Adding breakpoint into matches method of DB converter does not cause debugger to stop. But for controller converter it does.

Spring Boot version: 3.2.2

mp911de commented 7 months ago

Our CustomConversions supports only ConverterAware, GenericConverter, ConverterFactory and plain Converter. We do not support ConditionalConverter because CustomConversions determines convertible pairs before even applying the converter to build a registry of types that we can convert from/to. I created https://github.com/spring-projects/spring-data-commons/issues/3040 to document the supported types.