write method parameter type preferred over read method parameter type for property conversion (fixing regression; SPR-8964)

This commit is contained in:
Juergen Hoeller
2012-02-08 17:51:06 +01:00
parent 17bbc623c1
commit 4aa8b96687
3 changed files with 29 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.core.convert;
import java.lang.annotation.Annotation;
@@ -144,10 +145,7 @@ public final class Property {
if (read == null && write == null) {
throw new IllegalStateException("Property is neither readable nor writeable");
}
if (read != null && write != null && !write.getParameterType().isAssignableFrom(read.getParameterType())) {
throw new IllegalStateException("Write parameter is not assignable from read parameter");
}
return read != null ? read : write;
return (write != null ? write : read);
}
private MethodParameter resolveReadMethodParameter() {