Spring-boot: Spring-data-mongo converters not working

Created on 30 Oct 2019  路  6Comments  路  Source: spring-projects/spring-boot

Since the upgrade from Spring Boot 2.1.8 to 2.1.9 and 2.2.0 the following warning messages have started to be logged when running the test suite

WARN 364 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
and
WARN 364 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
external-project invalid

Most helpful comment

The change in behaviour appears to be caused by this commit in Spring Data MongoDB.

@Sparow199 Spring Data MongoDB uses JIRA for issue tracking. Can you please open an issue there and comment here with a link to it.

/cc @christophstrobl @mp911de

All 6 comments

Thanks for the report. We'll need some more details to figure out what's happening and if the problem is caused by Spring Boot or by Spring Data.

the following warning messages have started to be logged when running the test suite

What test suite are you referring to?

To help us to diagnose the problem, can you please provide a complete and minimal example that reproduces the problem as a zip attached to this issue?

Hi @wilkinsona ,
There is a whole project which could reproduce the issue

This is my convert:

    @Bean
    public MongoCustomConversions customConversions() {
        final List<Converter<?, ?>> converterList = new ArrayList<>();
        converterList.add(new CityReadConverter());
...
        return new MongoCustomConversions(converterList);
    }

@ReadingConverter
public class CityReadConverter implements Converter<Document, City> {

    @Override
    public City convert(@NotNull final Document source) {
        source.remove(METADATA);
        final Date lastUpdate = source.get(LAST_UPDATE, Date.class);
        if (Objects.nonNull(lastUpdate)) {
            source.put(LAST_UPDATE, lastUpdate.toString());
        }
...
        return city;
    }
}

At application startup:

2019-10-30 12:10:53.107 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.LocalDateTime to class org.joda.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.115 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.LocalDateTime to class org.joda.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.117 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.117 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.367 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.LocalDateTime to class org.joda.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.369 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.LocalDateTime to class org.joda.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.370 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-30 12:10:53.370 [restartedMain] WARN o.s.data.convert.CustomConversions - Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.

The application doesn't run with 2.1.9 and 2.2.0.

We experienced the same issue during Spring Boot 2.1 to 2.2 migration

An "empty" Spring Boot 2.1.9 application with a dependency on spring-boot-starter-data-mongodb produces the following warnings on start up:

2019-10-31 10:19:00.137  WARN 87776 --- [           main] o.s.data.convert.CustomConversions       : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-31 10:19:00.137  WARN 87776 --- [           main] o.s.data.convert.CustomConversions       : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-31 10:19:00.191  WARN 87776 --- [           main] o.s.data.convert.CustomConversions       : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2019-10-31 10:19:00.192  WARN 87776 --- [           main] o.s.data.convert.CustomConversions       : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.

The warnings disappear upon downgrading to Spring Data Lovelace-SR10.

The change in behaviour appears to be caused by this commit in Spring Data MongoDB.

@Sparow199 Spring Data MongoDB uses JIRA for issue tracking. Can you please open an issue there and comment here with a link to it.

/cc @christophstrobl @mp911de

Was this page helpful?
0 / 5 - 0 ratings