UI no responding after applying filter to the tree grid

Here is the code. and the attachement test\dfolder.zip is my test folder structure.

TreeGridWithFilter.java

public class TreeGridWithFilter extends VerticalLayout{
    
    private CheckBoxGroup<Boolean> readedFilter;
    private TreeGrid<FileWrapper> treeGrid;
    
    public TreeGridWithFilter() {
        super();
        readedFilter = new CheckBoxGroup<>("Readed Files");
        readedFilter.setItems(Boolean.TRUE, Boolean.FALSE);
        readedFilter.setItemCaptionGenerator(item->item?"readed":"unreaded");
        readedFilter.addValueChangeListener(event -> {
            Set<Boolean> values = event.getValue();
            
            ((TreeDataProvider<FileWrapper>)treeGrid.getDataProvider()).setFilter(t -> { 
                if(values == null || values.size() == 0) {
                    return true;
                }
                return t.getFileType().equals(FILE_TYPE.FOLDER) || values.contains(t.isReaded());
            });
        });
        
        TreeData<FileWrapper> treeData = new TreeData<>();
        buildTreeData(treeData, null, new FileWrapper(new File("/Users/hay/develop/0")));//need to change to your file path
        treeGrid = new TreeGrid<>(new TreeDataProvider<>(treeData ));
        treeGrid.addColumn(source -> source.getFileType().getIcon().getHtml() + source.getFile().getName(), new HtmlRenderer()).setCaption("Name");
        
        addComponents(readedFilter, treeGrid);
    }
    
    private void buildTreeData(TreeData<FileWrapper> treeData, FileWrapper parentFileWrapper, FileWrapper fileWrapper) {

        if (fileWrapper.getFile().exists()) {
            treeData.addItem(parentFileWrapper, fileWrapper);
            if(fileWrapper.getFile().isDirectory()) {
                File[]files = fileWrapper.getFile().listFiles();
                if (files == null || files.length == 0) {
                    return;
                } else {
                    for (File file2 : files) {
                        if (file2.isDirectory()) {
                            buildTreeData(treeData, fileWrapper, new FileWrapper(file2));
                        } else {
                            treeData.addItem(fileWrapper, new FileWrapper(file2));
                        }
                    }
                }     
            }
        }
    }
}

FileWrapper.java

public class FileWrapper{
    
    private final File file;
    private boolean readed;
    private FILE_TYPE fileType;
    
    public enum FILE_TYPE{
        FOLDER(VaadinIcons.FOLDER),
        FILE(VaadinIcons.FILE);
        
        private VaadinIcons icon;
        
        private FILE_TYPE(VaadinIcons icon) {
            this.icon = icon;
        }
        public VaadinIcons getIcon() {
            return icon;
        }
    }
    
    public FileWrapper(File file) {
        this(file,Math.random()>0.5);
    }
    
    public FileWrapper(File file, boolean readed) {
        this.file = file;
        setReaded(readed);
        if(file.isDirectory()) {
            setFileType(FILE_TYPE.FOLDER);
        }
        if(file.isFile()) {
            setFileType(FILE_TYPE.FILE);
        }
    }
    
    public File getFile() {
        return file;
    }
    
    public FILE_TYPE getFileType() {
        return fileType;
    }
    
    public void setFileType(FILE_TYPE fileType) {
        this.fileType = fileType;
    }
    
     public boolean isReaded() {
        return readed;
    }
    
    public void setReaded(boolean readed) {
        if(file.isFile())
        {
            this.readed = readed;
        } else
        {
            this.readed = false;
        }
    }
    
    @Override
    public boolean equals(Object obj) {
        if(!(obj instanceof FileWrapper)) {
            return super.equals(obj);
        } else {
            return this.getFile().equals(((FileWrapper)obj).getFile());
        }
    }
    
    @Override
    public int hashCode() {
        return this.getFile().hashCode();
    }
}

MyUI.java

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        setContent(new TreeGridWithFilter());
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

In my case, after apply the ‘unread’ filter to folder 11, there should be no files under this folder. But it still shows a caret-right icon. After I click it, the tree do not have any respond any more.
41505.zip (6.24 KB)

I made a video to record this issue, but can not add as an attachment(It is only 700k, not sure why). I can send through email if you guys want it :slight_smile:

Anyone to discuss about this issue?