Bug 1033612 - Incremental compilation is not correctly synchronized
Summary: Incremental compilation is not correctly synchronized
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: ER6
: 6.0.0
Assignee: Mario Fusco
QA Contact: Marek Winkler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-22 13:54 UTC by Mario Fusco
Modified: 2014-08-06 20:15 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:15:57 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DROOLS-350 0 Major Resolved Incremental compilation is not correctly synchronized 2015-05-20 15:33:49 UTC

Description Mario Fusco 2013-11-22 13:54:44 UTC
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";
    }

Comment 1 Mario Fusco 2013-11-22 13:55:54 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/60d27c063

Comment 3 Marek Winkler 2014-01-03 14:59:16 UTC
Verified on BRMS 6.0.0 ER6.


Note You need to log in before you can comment on or make changes to this bug.