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

Concurrency issue in WpdExtendlet

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.5.0
    • 8.0.3, 8.0.5
    • None
    • Security Level: Jimmy
    • None
    • None

      Steps to Reproduce

      Put a breakpoint in
      org.zkoss.zk.ui.http.WpdExtendlet.Content.parse(RequestContext) (line 627)
      at if (_cnt instanceof SourceInfo) in the following:

      private Object parse(RequestContext reqctx) throws ServletException, IOException {
      			if (_cnt instanceof SourceInfo)
      				try {
      					_cnt = ((SourceInfo) _cnt).parse(reqctx);
      				} catch (IOException ex) {
      					throw ex;
      				} catch (ServletException ex) {
      					throw ex;
      				} catch (Exception ex) {
      					throw UiException.Aide.wrap(ex);
      				}
      			return _cnt;
      		}
      

      Open a first ZK page on this server (Thread 1)
      ON THREAD 1 - Resume until _cnt value is a SourceInfo object
      ON THREAD 1 - Once _cnt is a SourceInfo instance, step inside the if statement, and stop before executing "_cnt = ((SourceInfo) _cnt).parse(reqctx);"
      Open a 2nd ZK page in a difference tab (Thread 2)
      ON THREAD 2 - resume the debugger until _cnt is NOT an instance of SourceInfo
      ON THREAD 1 - resume the thread

      Current Result

      Exception thrown:

      org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [auEngine] in context with path [/Gui] threw exception
       java.lang.ClassCastException: org.zkoss.zk.ui.http.WpdExtendlet$ByteContent cannot be cast to org.zkoss.zk.ui.http.WpdExtendlet$SourceInfo
      at org.zkoss.zk.ui.http.WpdExtendlet$Content.parse(WpdExtendlet.java:629)
      

      And the page request returns unavailable since this happen during the filter chain

      Expected Result

      Pages should be displayed

      Debug Info

      Root Cause

      Caused by static inner class Content field _cnt, accessed from multiple threads at the same time

      Workaround

      Attached replacement class in archive 20170508-WPDExtendletOverride, to add to the classPath while preserving it's package location.
      Note: Performance may be affected by this workaround

            wenninghsu wenninghsu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours
                5h