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

Include in defer mode fails if src is modified while the page is still loading

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • 6.5.8.1, 8.6.1
    • Components
    • Security Level: Jimmy
    • ZK 8.6.2 S2
    • None

      Steps to Reproduce

      Run fiddle
      http://zkfiddle.org/sample/ac8p6b/1-include-defer-mode-fails-changed-while-loading

      • on page load, the include receive src="in.zul?val=1"
      • during the rendering of in.zul, the include src is updated to src="in.zul?val=2"
        (include is in auto mode, which act as defer due to ?params in the url)

      Current Result

      include returns

      Cause: Unknown exception: java.lang.NullPointerException.
      java.lang.NullPointerException
      	at org.zkoss.zk.ui.sys.HtmlPageRenders.outPageContent(HtmlPageRenders.java:583)
      

      Expected Result

      include should output the 2nd page

      Debug Info

      Sequence of events:

      • Outer page is loaded.
      • Include in defer mode is instantiated
      • Include does
        https://github.com/zkoss/zk/blob/master/zk/src/org/zkoss/zk/ui/http/ExecutionImpl.java#L201
        org.zkoss.zk.ui.http.ExecutionImpl.include(Writer, String, Map<String, ?>, int)
        to output the included page (innerpage#1)
      • While the page is rendering, something happen in the inner page which changes the source of the outer include component. (in fiddle, it's a direct setter, but can be any indirect action such as event queues, commands, global commands, callbacks, etc...)
      • include.setSrc will trigger invalidate on include, and create a new inner page (innerpage#2)
        https://github.com/zkoss/zk/blob/master/zul/src/org/zkoss/zul/Include.java#L295
      • Invalidated include will cause pageImpl.destroy() to trigger on innerpage#1, which removes the desktop from innerpage#1
      • innerpage#2 will finish rendering and return.
      • innerpage#1 will continue rendering and fail, since it now missing a desktop, causing NPE and preventing the innerpage#2 from being rendered.
        --Note: in this scenario, even if the desktop exception didn't happen, the resulting page would be innerpage#1, since it will finish resolving after innerpage#2 and overwrites the result.

      Root Cause

      Include in defer mode source is changed while the first include is still rendering the page

      Workaround

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 3 days Original Estimate - 3 days
                3d
                Remaining:
                Time Spent - 1 day, 30 minutes Remaining Estimate - 3 days
                3d
                Logged:
                Time Spent - 1 day, 30 minutes Remaining Estimate - 3 days
                1d 30m