restored original array behavior (no default growth of arrays)
This commit is contained in:
parent
4c75054f90
commit
b9fe1b3250
|
|
@ -859,7 +859,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
for (int i = length; i < Array.getLength(newArray); i++) {
|
for (int i = length; i < Array.getLength(newArray); i++) {
|
||||||
Array.set(newArray, i, newValue(componentType, name));
|
Array.set(newArray, i, newValue(componentType, name));
|
||||||
}
|
}
|
||||||
// TODO this is not efficient because conversion may create a copy ... set directly because we know its assignable.
|
// TODO this is not efficient because conversion may create a copy ... set directly because we know it is assignable.
|
||||||
setPropertyValue(name, newArray);
|
setPropertyValue(name, newArray);
|
||||||
return getPropertyValue(name);
|
return getPropertyValue(name);
|
||||||
}
|
}
|
||||||
|
|
@ -971,8 +971,6 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
oldValue = Array.get(propValue, arrayIndex);
|
oldValue = Array.get(propValue, arrayIndex);
|
||||||
}
|
}
|
||||||
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
||||||
// TODO review this grow algorithm along side the null gap algorithm for setting lists below ... the two are inconsistent
|
|
||||||
propValue = growArrayIfNecessary(propValue, arrayIndex, actualName);
|
|
||||||
Array.set(propValue, arrayIndex, convertedValue);
|
Array.set(propValue, arrayIndex, convertedValue);
|
||||||
}
|
}
|
||||||
catch (IndexOutOfBoundsException ex) {
|
catch (IndexOutOfBoundsException ex) {
|
||||||
|
|
@ -986,23 +984,24 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
pd.getReadMethod(), tokens.keys.length);
|
pd.getReadMethod(), tokens.keys.length);
|
||||||
List list = (List) propValue;
|
List list = (List) propValue;
|
||||||
int index = Integer.parseInt(key);
|
int index = Integer.parseInt(key);
|
||||||
|
int size = list.size();
|
||||||
Object oldValue = null;
|
Object oldValue = null;
|
||||||
if (isExtractOldValueForEditor() && index < list.size()) {
|
if (isExtractOldValueForEditor() && index < size) {
|
||||||
oldValue = list.get(index);
|
oldValue = list.get(index);
|
||||||
}
|
}
|
||||||
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
||||||
if (index < list.size()) {
|
if (index < size) {
|
||||||
list.set(index, convertedValue);
|
list.set(index, convertedValue);
|
||||||
}
|
}
|
||||||
else if (index >= list.size()) {
|
else if (index >= size && index < this.autoGrowCollectionLimit) {
|
||||||
for (int i = list.size(); i < index; i++) {
|
for (int i = size; i < index; i++) {
|
||||||
try {
|
try {
|
||||||
list.add(null);
|
list.add(null);
|
||||||
}
|
}
|
||||||
catch (NullPointerException ex) {
|
catch (NullPointerException ex) {
|
||||||
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
|
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
|
||||||
"Cannot set element with index " + index + " in List of size " +
|
"Cannot set element with index " + index + " in List of size " +
|
||||||
list.size() + ", accessed using property path '" + propertyName +
|
size + ", accessed using property path '" + propertyName +
|
||||||
"': List does not support filling up gaps with null elements");
|
"': List does not support filling up gaps with null elements");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue