Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-182

Timed rules can disrupt other activations as they are being fired

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Blocker
    • Resolution: Done
    • 5.5.1.Final, 6.0.0.Beta3
    • 5.5.1.Final, 6.0.0.Final
    • None
    • None
    • Hide

      String drl = "package org.drools.test; \n" +
      "import org.drools.Person; \n " +
      "global java.util.List list; \n" +
      "\n" +
      "\n" +
      "rule TimeConsumingRule\n" +
      "when \n" +
      " $p : Person( $n : name ) \n" +
      "then \n" +
      " System.out.println( Thread.currentThread().getName() + \"Ill continue later \" ); \n" +
      " Thread.sleep( 1000 ); \n" +
      " System.out.println( Thread.currentThread().getName() + \"Hello >> \" + $n );\n" +
      "end\n" +
      "\n" +
      "rule PreemptingRule\n" +
      "timer( expr:0 )\n" +
      "when\n" +
      " $p : Person()\n" +
      "then\n" +
      " System.out.println( Thread.currentThread().getName() + \"Take out \" + $p ); \n" +
      " retract( $p );\n" +
      "end\n" +
      "\n"
      ;

      This particular test case throws a NPE when the accessor $n tries to read the - retracted - Person's name. The exception is not thrown when the time is > 0

      Show
      String drl = "package org.drools.test; \n" + "import org.drools.Person; \n " + "global java.util.List list; \n" + "\n" + "\n" + "rule TimeConsumingRule\n" + "when \n" + " $p : Person( $n : name ) \n" + "then \n" + " System.out.println( Thread.currentThread().getName() + \"Ill continue later \" ); \n" + " Thread.sleep( 1000 ); \n" + " System.out.println( Thread.currentThread().getName() + \"Hello >> \" + $n );\n" + "end\n" + "\n" + "rule PreemptingRule\n" + "timer( expr:0 )\n" + "when\n" + " $p : Person()\n" + "then\n" + " System.out.println( Thread.currentThread().getName() + \"Take out \" + $p ); \n" + " retract( $p );\n" + "end\n" + "\n" ; This particular test case throws a NPE when the accessor $n tries to read the - retracted - Person's name. The exception is not thrown when the time is > 0

    Description

      Timer-driven rules are executed by separated thread. One such thread may retract a fact which is being used by the (main) thread in a rule being fired. This preemption will lead to a NPE

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            dsotty Davide Sottara (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: