Uploaded image for project: 'Byteman'
  1. Byteman
  2. BYTEMAN-50

Allow undesirable recursive triggering of rules to be avoided

    XMLWordPrintable

Details

    Description

      The rule execution engine should avoid triggering of rules when it is performing internal housekeeping operations such as trigger injection, rule lookup, type checking, compilation etc.

      The default helper should also provide a builtin operation which can be used to disable and,possibly, subsequently re-enable recursive triggering of rules by expressions executed in the BIND, IF or DO clause of a given rule during a specific rule firing.

      A use case for the latter is provided by the following rules which copy all string writes and newline writes to a print stream to System.out.

      RULE trace print stream write
      CLASS java.io.FileOutputStream
      METHOD <init>(String, boolean)
      AT ENTRY
      IF TRUE
      DO setTriggering(false),
      traceln("myFile", "open " + $1 + ($2 ? " for append" : "")),
      setTriggering(true)
      ENDRULE

      Without the bracketing calls to setTriggering this rule would blow up because at the first triggering. The traceln call tries to open a trace stream with key "myFile" and this recursively triggers the rule resultign in a stack overflow. n.b. adding a separate rule to do a traceOpen for the key does not get round this since the traceOpen call will trigger this rule and blow up.

      Attachments

        Activity

          People

            rhn-engineering-adinn Andrew Dinn
            rhn-engineering-adinn Andrew Dinn
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: