Details

    • Type: Bug Bug
    • Status: Continued
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.7
    • Fix Version/s: None
    • Component/s: Blocks: Java Flow
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other

      Description

      I get an error whenever I include an <fd:selection-list src="cocoon:/XYZ"> where
      both the form and the XYZ pipeline use JavaFlow. The error is:

      No continuation is running
      cause: java.lang.IllegalStateException: No continuation is running
      java.lang.IllegalStateException: No continuation is running
      at
      org.apache.cocoon.components.flow.java.Continuation.suspend(Continuation.java:79)
      at
      org.apache.cocoon.components.flow.java.AbstractContinuable.sendPageAndWait(AbstractContinuable.java:75)
      at org.apache.cocoon.forms.flow.java.FormInstance.show(FormInstance.java:181)

      The reason is that when cocoon:/XYZ runs, a continuation is created for the same
      thread as the form continuation. The continuationsmap in Continuation class gets
      overwritten. When cocoon:/XYZ returns, the map is cleared for the thread,
      leaving no continuation for the form.

      Here's a bit of code from the app to help explain.

      The form contains a selection list defined as:
      <fd:field id="user">
         <fd:datatype base="string"/>
         <fd:selection-list src="cocoon:/UserSelectList" dynamic="true"/>
      </fd:field>

      The sitemap contains:
      <map:match pattern="UserSelectList">
         <map:call function="generateUserList"/>
      </map:match>

      Then I have the following JavaFlow
      public void doGenerateUserList() throws Exception {
         Collection userList = databaseManager.getUserList();
         sendPage("user_list", new VarMap().add("list", userList) );
      }

        Activity

        Hide
        Simone Gianni added a comment -
        I have it tested for javaflow 2.1, don't even know if 2.2 is affected by the same problem and if this is a good solution for it as well. Should ask Torsten. Anyway I'll commit the 2.1 fix ASAP.
        Show
        Simone Gianni added a comment - I have it tested for javaflow 2.1, don't even know if 2.2 is affected by the same problem and if this is a good solution for it as well. Should ask Torsten. Anyway I'll commit the 2.1 fix ASAP.
        Hide
        Jean-Baptiste Quenot added a comment -
        Simone, I think the patch can be applied. Or if it is not relevant anymore, we may close the issue.
        Show
        Jean-Baptiste Quenot added a comment - Simone, I think the patch can be applied. Or if it is not relevant anymore, we may close the issue.
        Hide
        Simone Gianni added a comment -
        Unfied diff of the given patch applied to latest Continuation.java.

        Tested that it works correctly with samples (that means, at least samples keep working) but not on the specified case of a flow calling another flow .. anyway theorically it should work.

        P.S. in doubt i marked the attachment as "not intended for inclusion", since IANAL and dunno if the original author granted the licence for incusion.
        Show
        Simone Gianni added a comment - Unfied diff of the given patch applied to latest Continuation.java. Tested that it works correctly with samples (that means, at least samples keep working) but not on the specified case of a flow calling another flow .. anyway theorically it should work. P.S. in doubt i marked the attachment as "not intended for inclusion", since IANAL and dunno if the original author granted the licence for incusion.
        Hide
        Jean-Baptiste Quenot added a comment -
        Could you please provide the patch as an attachment?
        Show
        Jean-Baptiste Quenot added a comment - Could you please provide the patch as an attachment?
        Hide
        Benoit Deshaies added a comment -
        I've implemented a way to fix it, but I doubt it's ideal. Ideally, the
        continuations would be tied to an invocation of the pipeline, not the current
        thread.

        My fix stores a map of key=current thread, value=stack of Continuation. When a
        new continuation is created, it is pushed onto the stack. When it ends, it is
        popped. Since the sitemap processing is hiherarchical, this should work. This
        does assume that registerThread() and deregisterThread() always called correctly.

        [from 2.1.7]
        diff Continuation.java Continuation_old.java

        19d18
        < import java.util.Stack;
        110,116c109
        < Thread t = Thread.currentThread();
        < Stack threadStack = (Stack)continuationsmap.get(t);
        < if (threadStack == null) {
        < threadStack = new Stack();
        < continuationsmap.put(t, threadStack);
        < }
        < threadStack.push(this);
        ---
        > continuationsmap.put(Thread.currentThread(), this);
        125,131c118
        < Thread t = Thread.currentThread();
        < Stack threadStack = (Stack)continuationsmap.get(t);
        < if (threadStack == null)
        < return;
        < threadStack.pop();
        < if (threadStack.isEmpty())
        < continuationsmap.remove(t);
        ---
        > continuationsmap.remove(Thread.currentThread());
        142,145c129
        < Stack threadStack = (Stack)continuationsmap.get(t);
        < if (threadStack == null || threadStack.isEmpty())
        < return null;
        < return (Continuation) threadStack.peek();
        ---
        > return (Continuation) continuationsmap.get(t);
        Show
        Benoit Deshaies added a comment - I've implemented a way to fix it, but I doubt it's ideal. Ideally, the continuations would be tied to an invocation of the pipeline, not the current thread. My fix stores a map of key=current thread, value=stack of Continuation. When a new continuation is created, it is pushed onto the stack. When it ends, it is popped. Since the sitemap processing is hiherarchical, this should work. This does assume that registerThread() and deregisterThread() always called correctly. [from 2.1.7] diff Continuation.java Continuation_old.java 19d18 < import java.util.Stack; 110,116c109 < Thread t = Thread.currentThread(); < Stack threadStack = (Stack)continuationsmap.get(t); < if (threadStack == null) { < threadStack = new Stack(); < continuationsmap.put(t, threadStack); < } < threadStack.push(this); --- > continuationsmap.put(Thread.currentThread(), this); 125,131c118 < Thread t = Thread.currentThread(); < Stack threadStack = (Stack)continuationsmap.get(t); < if (threadStack == null) < return; < threadStack.pop(); < if (threadStack.isEmpty()) < continuationsmap.remove(t); --- > continuationsmap.remove(Thread.currentThread()); 142,145c129 < Stack threadStack = (Stack)continuationsmap.get(t); < if (threadStack == null || threadStack.isEmpty()) < return null; < return (Continuation) threadStack.peek(); --- > return (Continuation) continuationsmap.get(t);

          People

          • Assignee:
            Unassigned
            Reporter:
            Benoit Deshaies
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development