vaadin / framework

Vaadin 6, 7, 8 is a Java framework for modern Java web applications.
http://vaadin.com/
Other
1.77k stars 729 forks source link

"Connector is no longer visible to the client, but no corresponding hierarchy change was sent" when hiding component in a background #12528

Closed fluorumlabs closed 2 years ago

fluorumlabs commented 2 years ago
Meta Value
Vaadin Framework 8.14.1

Overview

When assertions are enabled and certain component is hidden via ui.access(...), AssertError is thrown in com.vaadin.ui.ConnectorTracker.cleanConnectorMap(ConnectorTracker.java:349).

Description

The issue occurs when there are several open UIs and component visibility in one of them is changed in ui.access(...) block. Such blocks are executed before VaadinSession is unlocked right before connector hierarchy checks. When some component is hidden this way, and the currently handled request is for another UI instance, the client is not (yet) notified of those changes and the assertion code complains about it.

Reproduction

Project: https://github.com/fluorumlabs/vaadin8-connector-not-visible-issue/blob/master/src/main/java/org/test/MyUI.java

Steps to reproduce:

  1. Run project with enabled assertions (-ea argument added to VM options)
  2. Open two tabs pointing at http://localhost:8080
  3. Click Switch content on other tabs button on any of the tabs

Expected behavior

No exceptions throwables are thrown.

Actual behavior

Mar 14, 2022 1:09:20 PM com.vaadin.server.VaadinSession unlock
SEVERE: Exception while cleaning connector map for ui 1
java.lang.AssertionError: Connector com.vaadin.ui.VerticalLayout@4c621039 (id = 11) is no longer visible to the client, but no corresponding hierarchy change was sent.
    at com.vaadin.ui.ConnectorTracker.cleanConnectorMap(ConnectorTracker.java:349)
    at com.vaadin.ui.ConnectorTracker.cleanConnectorMap(ConnectorTracker.java:294)
    at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:1036)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:42)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1637)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:464)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        ...

Mar 14, 2022 1:09:20 PM com.vaadin.server.VaadinSession unlock
SEVERE: Exception while cleaning connector map for ui 1
java.lang.AssertionError: Connector com.vaadin.ui.Label@2e60a901 (id = 12) is no longer visible to the client, but no corresponding hierarchy change was sent.
    at com.vaadin.ui.ConnectorTracker.cleanConnectorMap(ConnectorTracker.java:349)
    at com.vaadin.ui.ConnectorTracker.cleanConnectorMap(ConnectorTracker.java:294)
    at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:1036)
    at com.vaadin.server.VaadinService.requestEnd(VaadinService.java:1491)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1651)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:464)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        ...
TatuLund commented 2 years ago

The fix will be included in Vaadin 8.16.0