Skip to content

Target type in Converter interface should be @Nullable #35947

@OrangeDog

Description

@OrangeDog

org.springframework.core.convert.converter.Converter is in a @NullMarked package, so all types are @NonNull by default.

All uses of T are @Nullable, but the type parameter itself is not. This leads to non-intuitive code such as:

Converter<@NonNull Source, @NonNull Target> converter;
// ...
@Nullable Target t = converter.convert(s);

The convert method itself ends up annotated as @Nullable @NonNull T.

As far as I can see, the solution is to just annotate the parameter declaration, and nothing should break?

public interface Converter<S, @Nullable T> {

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions