Skip to content

NPE in FileBuilder class #17

@RemusSino

Description

@RemusSino

In Exporter there is the constructor with one argument - Container container. This calls the constructor with two arguments - Container container, Object[] visibleColumns , with null value for visibleColumns. In this constructor, the call this.setContainerToBeExported(container) , eventually creates the FileBuilder and ends up in the setContainer(container) method which also set's the visibleColumns. Then in the same constructor you set again the visibleColumns, to null this time, because it is the value passed in as parameter.
This leads to NPE in FileBuilder in methods like buildColumnHeaders, where you check the length on the visibleColumns array which is in fact null - if (this.visibleColumns.length != 0) .

My solution:

    public Exporter(Container container, Object[] visibleColumns) {
        this();
        this.setCaption("Exporter");
//set visible columns first
        this.setVisibleColumns(visibleColumns);
//then, the container
        this.setContainerToBeExported(container);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions