Uploaded image for project: 'Policy Framework'
  1. Policy Framework
  2. POLICY-2463

In APEX Policy javascript task logic, JSON.stringify causing stackoverflow exceptions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • Guilin Release
    • Frankfurt Release
    • None
    • Policy 5/26-6/5, Policy 6/8-6/19, Policy 9/16-9/30, Policy 10/1 - 10/15, Policy 11/12-11/30

      JSON.stringify results in stackoverflow only when the fields added to the dictionary(which is tried to be coverted to json string using stringify) are of type objects.  

      // say the input json event which is taken in the task logic is having a string field nfName, for e.g. "nfName": "pnf300"

      var nfName = executor.inFields.get("nfName")  //typeof nfName is object here

      var obj = {};
      obj["nf-name"] = nfName
      JSON.stringify(obj), this is causing stackoverflow.

      Changing to obj["nf-name"] =String(nfName) solves the issue.
       
      So, if key/value getting assigned is of type object, casting them to String is the workaround to fix this bug with Rhino, as shown below.

      obj[String(key)] = String(value)
       
      Need further analysis on this, or track this existing bug in Rhino

            liamfallon liamfallon
            a.sreekumar a.sreekumar
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: