Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-997

Flow - Implicit variable declaration causes double setup/invalidate of FOM_Cocoon

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.2
    • None
    • - Flowscript
    • None
    • Operating System: other
      Platform: Other
    • 25951

    Description

      While making my own flowscripts using JXForms + flowscript I found that
      implicit variable declaration (without var) in nested validation function will
      cause very weird mixup of two FOM_Cocoon instances and it causes double calling
      setup() and later invalidate() on same FOM_Coccon instance.

      This causes NullPointerException in Cocoon 2.1.2 (FOM_Coccon.invalidate) and is
      worked around (or rather masked) in revision 1.15 of FOM_Cocoon.java.
      However it does not solve the problem.

      Howto reproduce
      ---------------
      Edit feedbackWizard.js in samples/jxforms - add implicit variable 'carshMe'
      there:
          form.sendView("wizard/deployment.xml",
                        function(form) {
              var bean = form.getModel();
      crashMe = new java.util.Date(); // XXX: note missing var
      cocoon.log.info("dddd: "+crashMe);

              cocoon.log.info("I can also do validation in JavaScript");
              if (bean.publish) {
                  form.addViolation("/publish", "Sorry, I won't let you publish");
              }
          });

      After calling this validation function and making further actions (back and
      submit etc) - this will cause NullPointerExeption in Cocoon 2.1.2, because two
      instances of FOM_Coccon (one for Function Call and later for Continuation) are
      mixed now - both FOM_JavaScriptInterpreter.callFunction and handleContinuation
      will now call cocoon.setup() and cocoon.invalidate() 2 times on same instance!

      Workaround
      ----------
      is simple. Never forget to declare variables using var, i.e.:
       replace
      crashMe = new java.util.Date(); // XXX: note missing var
       with
      var crashMe = new java.util.Date();
      (note - restart jetty after that change to clear session state, otherwise the
      problem will persist).


      --------------------
      Unfortunately I do not know what is the real difference between implicit
      declaration and explicit var declaration, but it seems to have strange
      effects...

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hpaluch@gitus.cz Henryk Paluch
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: