Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5730

Harden smartUpdate to check for null desktop or null webapp

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 10.1.0
    • 10.0.0, 9.6.5
    • None
    • Security Level: Jimmy

      reproducing case

      Run attached sample
      Click button

      current result

      runnable - run()
      14:49:45.960 [qtp1668627309-29] ERROR org.zkoss.zk.ui.impl.DesktopImpl -- Exception occured while processing scheduled server push
      java.lang.NullPointerException: Cannot invoke "org.zkoss.zk.ui.Desktop.getWebApp()" because the return value of "org.zkoss.zk.ui.Page.getDesktop()" is null
      	at org.zkoss.zk.ui.AbstractComponent.getAttachedUiEngine(AbstractComponent.java:375)
      	at org.zkoss.zk.ui.AbstractComponent.smartUpdate(AbstractComponent.java:1864)
      	at org.zkoss.zk.ui.AbstractComponent.smartUpdate(AbstractComponent.java:1838)
      	at org.zkoss.zk.ui.HtmlBasedComponent.setSclass(HtmlBasedComponent.java:359)
      	at org.zkoss.zk.ui.HtmlBasedComponent.addSclass(HtmlBasedComponent.java:380)
      	at ScheduleComposerSimple_16678.lambda$1(ScheduleComposerSimple_16678.java:31)
      	at java.base/java.util.Optional.ifPresent(Optional.java:178)
      	at ScheduleComposerSimple_16678.executeEventListener(ScheduleComposerSimple_16678.java:43)
      	at org.zkoss.zk.ui.impl.DesktopImpl$ScheduleInfo.invoke(DesktopImpl.java:1880)
      	at org.zkoss.zk.ui.impl.DesktopImpl$ScheduleListener.onEvent(DesktopImpl.java:1899)
      	at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3191)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3161)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3103)
      	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1884)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1656)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1323)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:571)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:451)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:459)
      	...
      

      expected result

      no exception, silently ignore of no page / desktop / webapp

      debugging information

      Reproducing case forces the error case, but it also happen in production.
      production case doesn't manually destroys page, and is hard to track why the desktop / webapp might be null

      Steps to reproduce: case 2

      1. open 2 browser tabs for zk-3729.zul
      2. in the 1st tab, click "sync long op"
      3. quickly change to the 2nd tab, click "log out" button ((SimpleSession)Sessions.getCurrent()).invalidateNow();

      Current Result

      java.lang.NullPointerException: Cannot invoke "org.zkoss.zk.ui.Desktop.getWebApp()" because the return value of "org.zkoss.zk.ui.Page.getDesktop()" is null
      at org.zkoss.zk.ui.AbstractComponent.getAttachedUiEngine(AbstractComponent.java:380)
      at org.zkoss.zk.ui.AbstractComponent.smartUpdate(AbstractComponent.java:1863)
      at org.zkoss.zk.ui.AbstractComponent.smartUpdate(AbstractComponent.java:1837)
      at org.zkoss.zk.ui.HtmlBasedComponent.setSclass(HtmlBasedComponent.java:359)
      at org.zkoss.zk.ui.HtmlBasedComponent.addSclass(HtmlBasedComponent.java:380)
      at bug.ZK3729Composer.longOp(ZK3729Composer.java:33)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)

      Expected result

      no error on the page

        1. ScheduleComposerSimple_16678.java
          1 kB
          MDuchemin
        2. test.zul
          0.2 kB
          MDuchemin
        3. zk-3729.zul
          0.2 kB
          hawk
        4. ZK3729Composer.java
          1 kB
          hawk

            jumperchen jumperchen
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: