Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlexRoig opened this issue May 17, 2022 · 0 comments
Open

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

AlexRoig opened this issue May 17, 2022 · 0 comments

Comments

@AlexRoig
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant