Skip to content

Duplicate ModelConverter registration with Spring Boot DevTools #2939

Closed
@SamuelGuillemet

Description

@SamuelGuillemet

Hello,

I've recently encountered a new bug.

Issue Description:

Describe the bug
A newly created ModelConverter is being registered in duplicate when used with Spring Boot DevTools, due to the class loader being different.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Spring Boot application and include Spring Boot DevTools.
  2. Add a new ModelConverter and annotate it with @Component
@Component
public final class OwnConverter implements ModelConverter {

    @Override
    public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
        return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null;
    }
}

Expected behavior
The ModelConverter should be registered only once but every time the devtool restart the app, a new OwnConverter is added to the list of converters.

Additional context
I think the issue might comes from the following line where the comparaison is done through reference equality.
ModelConverterRegistrar.java#L102

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions