Skip to content

BeanWrapperImpl: wrong null treatment in array properties [SPR-1823] #6517

@spring-projects-issues

Description

@spring-projects-issues

Fabio Grassi opened SPR-1823 and commented

Assignig a null value to an array property results in an array with a single null element. I think this is a regression, but was not able to determine exactly. Here is a test case:

public class ArrayBug {

public static void main(String[] args) {
    BeanWrapper bw = new BeanWrapperImpl(BeanWithArrayProperty.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("elements", null);
    bw.setPropertyValues(pvs);
    BeanWithArrayProperty bwap = (BeanWithArrayProperty) bw.getWrappedInstance();
    Assert.isNull(bwap.getElements());
}


public static class BeanWithArrayProperty {
    private Integer[] elements;

    public Integer[] getElements() {
        return elements;
    }

    public void setElements(Integer[] elements) {
        this.elements = elements;
    }
    
}

}

Thanks in advance, Fabio.


Affects: 1.2.7

Issue Links:

1 votes, 0 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions