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

Concurrency issue in WpdExtendlet

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.0.3, 8.0.5
    • Fix Version/s: 8.5.0
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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