Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-1085

Rule fires before calling fireAllRules

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.0.0.GA
    • Fix Version/s: 4.0.1
    • Component/s: None
    • Labels:
      None

      Description

      Modifying the main method of the program fragment used in ( http://jira.jboss.com/jira/browse/JBRULES-1079 ) to

      public static void main(String ... args) {
      try

      { DroolsTest test=new DroolsTest(new File(args[0])); SpecialString first42 =new SpecialString("42"); SpecialString second42=new SpecialString("42"); System.out.println("Inserting ..."); test.getSession().insert(new SpecialString("World")); test.getSession().insert(first42); test.getSession().insert(second42); System.out.println("Done."); System.out.println("Firing rules ..."); test.getSession().fireAllRules(); System.out.println("Done."); }

      catch (Exception ex)

      { ex.printStackTrace(); }

      }

      and using the rule

      package test

      rule "Strange rule"

      when
      not(exists(x : SpecialString() and
      forall(y : SpecialString(this!=x)
      SpecialString(this==y, text=="Universe"))))

      then
      System.out.println("Condition satisfied");
      end

      leads to the following output:

      Condition satisfied
      Inserting ...
      Done.
      Firing rules ...
      Condition satisfied
      Done.

      The Drools Engine fires the rule before the method fireAllRules() is called in the main method. As a result,

      System.out.println("Condition satisfied");

      is executed twice.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mark.proctor Mark Proctor
                Reporter:
                marreitz Markus Reitz
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: