-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
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"; }