- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Description
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:
- ClassCastException possible when converting to a target type that is a subtype of T for a Converter<S, T> convertible type. [SPR-8718] #13360 ClassCastException possible when converting to a target type that is a subtype of T for a Converter<S, T> convertible type.
- INT-3556 Use Converters that can convert to subtype of datatype channel
0 votes, 7 watchers
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement