Skip to content

GenericConversionService should match target converters for compatible subclasses [SPR-8675] #13317

@spring-projects-issues

Description

@spring-projects-issues

David Smiley opened SPR-8675 and commented

I registered this simple Converter (which by the way, I feel is something that should be out of the box):

public class FileToResourceConverter implements Converter<File,Resource> {
  public Resource convert(File source) {
    return new FileSystemResource(source);
  }
}

I have code that would like to look up a converter for an InputStreamSource (a super-interface of Resource):

InputStreamSource rsrc = this.getConversionService().convert(message.getPayload(), InputStreamSource.class);

But this fails because, apparently, GenericConversionService is unable to recognize instanceof relationships between the conversion target type and the desired target type. As a workaround, my code here has to be aware that the converter is for Resource and then ask the conversion service for a Resource even though it only needs an InputStreamSource.


Affects: 3.0.6

Issue Links:

0 votes, 7 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions