vaadin / flow-components

Java counterpart of Vaadin Web Components
101 stars 66 forks source link

Vaadin Flow Spreadsheet brakes serialization #6612

Open AndriiRevaEpicor opened 2 months ago

AndriiRevaEpicor commented 2 months ago

Description

When we want to use Session replication using by Vaadin along with kubernetes-kit and Vaadin Flow Spreadsheet then the issue will occur that SpreadsheetHandlerImpl.java doesn't serializable.

Added link to a test project which help to reproduce this issue.

Stacktrace which describe the issue was added to the project and here as well. (non_serializable_issue_logs.txt)

Expected outcome

I'd like to expect that Vaadin Flow Spreadsheet is fully serializable that I can use it along with Session replication.

Minimal reproducible example

@Route
public class MainView extends VerticalLayout {

    private transient final Spreadsheet spreadsheet = new Spreadsheet();

    public MainView() {
        this.add(this.spreadsheet);
    }
}

Steps to reproduce

  1. Run application with two VM options to make sure that serializable logs shows: --add-opens java.base/java.io=ALL-UNNAMED -Dsun.io.serialization.extendedDebugInfo=true
  2. Check application logs and make sure that stacktrace the same as I attached to this github issue - (non_serializable_issue_logs.txt).

Environment

Vaadin version(s): 24.4.11 Kubernetes Kit version: 2.2.2 OS: Windows 11

Browsers

Issue is not browser related

sissbruecker commented 2 months ago

That is a know limitation of the component: https://vaadin.com/docs/latest/components/spreadsheet#limitations

TatuLund commented 2 months ago

I did some exploration on this. By introducing Serializable wrappers for the classes maintained in Spreadsheet state such as cell reference and cell range, making WeakHashMaps transients, Workbook etc. It could be possible to make it work. It may introduce breaking change. Especially that Workbook being transient and lost during serialization, so there should be a new API to set provider function for it or some other approach.

But Workbook being transient means that the burden for the user of Spreadsheet is not significantly different of making the whole Spreadsheet transient and re-create if is null after serialization.