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

Incremental compilation is not correctly synchronized

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 6.0.1.Final
    • Component/s: None
    • Labels:
      None

      Description

      Incremental compilation is not correctly synchronized and then a kiesession can fire when the underlying rule base is in an inconsistent state. The test case below shows the problem

          @Test(timeout = 10000)
          public void testIncrementalCompilationSynchronization() throws Exception {
              final KieServices kieServices = KieServices.Factory.get();
      
              ReleaseId releaseId = kieServices.newReleaseId("org.kie.test", "sync-scanner-test", "1.0.0");
              createAndDeployJar( kieServices, releaseId, createDRL("rule0") );
      
              final KieContainer kieContainer = kieServices.newKieContainer(releaseId);
      
              KieSession kieSession = kieContainer.newKieSession();
              List<String> list = new ArrayList<String>();
              kieSession.setGlobal("list", list);
              kieSession.fireAllRules();
              kieSession.dispose();
              assertEquals(1, list.size());
      
              Thread t = new Thread(new Runnable() {
                  @Override
                  public void run() {
                      for (int i = 1; i < 10; i++) {
                          ReleaseId releaseId = kieServices.newReleaseId("org.kie.test", "sync-scanner-test", "1.0." + i);
                          createAndDeployJar( kieServices, releaseId, createDRL("rule" + i) );
                          kieContainer.updateToVersion(releaseId);
                      }
                  }
              });
      
              t.setDaemon(true);
              t.start();
      
              while (true) {
                  kieSession = kieContainer.newKieSession();
                  list = new ArrayList<String>();
                  kieSession.setGlobal("list", list);
                  kieSession.fireAllRules();
                  kieSession.dispose();
                  assertEquals(1, list.size());
                  if (list.get(0).equals("rule9")) {
                      break;
                  }
              }
          }
      
          private String createDRL(String ruleName) {
              return "package org.kie.test\n" +
                     "global java.util.List list\n" +
                     "rule " + ruleName + "\n" +
                     "when\n" +
                     "then\n" +
                     "list.add( drools.getRule().getName() );\n" +
                     "end\n";
          }
      

        Attachments

          Activity

            People

            Assignee:
            mfusco Mario Fusco
            Reporter:
            mfusco Mario Fusco
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: