Refine conversion service type check

Update fix to account for primitive types.

See gh-28592
This commit is contained in:
Phillip Webb 2022-06-10 16:12:38 -07:00
parent 31b0264d94
commit 63fdd729f5
2 changed files with 3 additions and 2 deletions

View File

@ -42,6 +42,7 @@ import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.ConditionalGenericConverter;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
/**
@ -107,7 +108,7 @@ final class BindConverter {
try {
if (delegate.canConvert(sourceType, targetType)) {
Object converted = delegate.convert(source, sourceType, targetType);
if (targetType.getType().isInstance(converted)) {
if (ClassUtils.isAssignableValue(targetType.getType(), converted)) {
return converted;
}
}

View File

@ -40,4 +40,4 @@ public class WithPublicObjectToObjectMethod {
return Optional.of(new WithPublicObjectToObjectMethod(value));
}
}
}