Merge branch '6.1.x'

This commit is contained in:
Sam Brannen
2024-08-04 17:14:10 +03:00
2 changed files with 5 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ import org.springframework.util.ObjectUtils;
*
* @author Keith Donald
* @author Phillip Webb
* @author Sam Brannen
* @since 3.0
*/
final class ArrayToArrayConverter implements ConditionalGenericConverter {
@@ -64,8 +65,8 @@ final class ArrayToArrayConverter implements ConditionalGenericConverter {
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (this.conversionService instanceof GenericConversionService genericConversionService) {
TypeDescriptor targetElement = targetType.getElementTypeDescriptor();
if (targetElement != null && genericConversionService.canBypassConvert(
sourceType.getElementTypeDescriptor(), targetElement)) {
if (targetElement != null && targetType.getType().isInstance(source) &&
genericConversionService.canBypassConvert(sourceType.getElementTypeDescriptor(), targetElement)) {
return source;
}
}