Skip to content

Vaadin 23.1.0beta1 + Filters and non-recursive exception #6

@AlexRoig

Description

@AlexRoig

Hi,

First of all, congrats for such a great extension!!

I found an issue when I configure the FileSystemDataProvider as non-recursive and with some filters to hide Thumbs.db and .DS_Store files.

        FilesystemData root = new FilesystemData(directory, false); //Setting to true, avoids exception
        FilesystemDataProvider fileSystem = new FilesystemDataProvider(root);
        fileSystem.addFilter(file -> !file.getName().endsWith(".db")); //Remove Thumbs.db
        fileSystem.addFilter(file -> !file.getName().equals(".DS_Store")); //Remove DS_Store
        Tree<File> tree = new Tree<>();
        tree.setDataProvider(fileSystem);
        tree.addHierarchyColumn(File::getName, FileTypeResolver::getIcon, this::getFileDescription)
                .setAutoWidth(true).setResizable(true).setHeader("File");
        tree.expand(directory); //Open root directory

The exception happens when I expand a directory on the second level order that has something filtered. I'm not really sure if the exception happens because of the deeper implementation of Vaadin TreeDataProvider

// When I expanded the directory, it has 4 items,and one of them is filtered.
java.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[na:na]
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[na:na]
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[na:na]
	at java.base/java.util.Objects.checkIndex(Objects.java:359) ~[na:na]
	at java.base/java.util.ArrayList.get(ArrayList.java:427) ~[na:na]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.lambda$getJsonItems$5(HierarchicalCommunicationController.java:323) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]
	at java.base/java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180) ~[na:na]
	at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104) ~[na:na]
	at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:711) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.getJsonItems(HierarchicalCommunicationController.java:325) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.set(HierarchicalCommunicationController.java:208) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]
	at com.vaadin.flow.data.provider.hierarchy.HierarchicalCommunicationController.collectChangesToSend(HierarchicalCommunicationController.java:177) ~[flow-data-23.1.0.beta1.jar:23.1.0.beta1]

Regards,
Alex

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