Skip to content

Redundant registration of Date/Calendar/Long converters in DefaultFormattingConversionService #36951

@itaming

Description

@itaming

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:

  • DateToLongConverter
  • DateToCalendarConverter
  • CalendarToDateConverter
  • CalendarToLongConverter
  • LongToDateConverter
  • LongToCalendarConverter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions