Redundant registration of Date/Calendar/Long converters in DefaultFormattingConversionService
While debugging WebConversionService initialization, I noticed that DateFormatterRegistrar.addDateConverters(...) appears to be invoked twice during the setup of the default formatting conversion service.
The call path is:
DefaultFormattingConversionService.addDefaultFormatters(FormatterRegistry formatterRegistry)
├─ new DateTimeFormatterRegistrar().registerFormatters(formatterRegistry)
│ └─ DateTimeConverters.registerConverters(registry)
│ └─ DateFormatterRegistrar.addDateConverters(registry)
└─ new DateFormatterRegistrar().registerFormatters(formatterRegistry)
└─ addDateConverters(registry)
As a result, the following converters are registered twice:
DateToLongConverterDateToCalendarConverterCalendarToDateConverterCalendarToLongConverterLongToDateConverterLongToCalendarConverter
When inspecting the internal converter registry, I can see duplicate converter instances for the same source/target type pairs.
I understand that this does not appear to cause any functional issues, since conversion behavior remains unchanged. However, the duplicate registrations seem redundant and may introduce unnecessary converter instances in the registry.
I may be missing some historical context here, but I wanted to check whether this duplication is expected or if it could be simplified.
I had a quick look at the registration path.
It looks like the duplicate registrations come from DateTimeFormatterRegistrar
calling DateTimeConverters.registerConverters(...), which currently delegates to
DateFormatterRegistrar.addDateConverters(...), and then
DefaultFormattingConversionService.addDefaultFormatters(...) registers
DateFormatterRegistrar as well.
I agree this does not appear to change conversion behavior, but it does create duplicate converter instances for the same source/target pairs.
If the team considers this worth simplifying, I can explore a small change that
keeps standalone DateTimeFormatterRegistrar behavior intact while avoiding the
duplicate registration in DefaultFormattingConversionService.