[jboss-jira] [JBoss JIRA] (DROOLS-523) KieContainer#updateToVersion does not update globals

Mario Fusco (JIRA) issues at jboss.org
Fri Jun 27 08:09:25 EDT 2014


     [ https://issues.jboss.org/browse/DROOLS-523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mario Fusco updated DROOLS-523:
-------------------------------

    Labels: backport-to-6.0.x  (was: )


> KieContainer#updateToVersion does not update globals
> ----------------------------------------------------
>
>                 Key: DROOLS-523
>                 URL: https://issues.jboss.org/browse/DROOLS-523
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 6.0.0.Final
>            Reporter: Mike Wilson
>            Assignee: Mario Fusco
>              Labels: backport-to-6.0.x
>             Fix For: 6.1.0.Final
>
>
> When the original version of a KieModule does not contain a given global, but the new version does, it is impossible to set the global after upgrading from the original version to the new version.
> The following unit test can be added to [IncrementalCompilationTest.java|https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java] and executed to demonstrate the problem:
> {code:title=IncrementalCompilationTest.java}
>     @Test
>     public void testKJarUpgradeSameSessionAddingGlobal() throws Exception {
>         String drl1 = "package org.drools.compiler\n" +
>                 "rule R1 when\n" +
>                 "   $m : Message()\n" +
>                 "then\n" +
>                 "end\n";
>         String drl2_1 = "package org.drools.compiler\n" +
>                 "rule R2_1 when\n" +
>                 "   $m : Message( message == \"Hi Universe\" )\n" +
>                 "then\n" +
>                 "end\n";
>         String drl2_2 = "package org.drools.compiler\n" +
>         		"global java.lang.String foo\n" +
>                 "rule R2_2 when\n" +
>                 "   $m : Message( message == \"Hello World\" )\n" +
>                 "then\n" +
>                 "end\n";
>         KieServices ks = KieServices.Factory.get();
>         // Create an in-memory jar for version 1.0.0
>         ReleaseId releaseId1 = ks.newReleaseId( "org.kie", "test-upgrade", "1.0.0" );
>         KieModule km = createAndDeployJar( ks, releaseId1, drl1, drl2_1 );
>         // Create a session and fire rules
>         KieContainer kc = ks.newKieContainer( km.getReleaseId() );
>         KieSession ksession = kc.newKieSession();
>         ksession.insert( new Message( "Hello World" ) );
>         assertEquals( 1, ksession.fireAllRules() );
>         // Create a new jar for version 1.1.0
>         ReleaseId releaseId2 = ks.newReleaseId( "org.kie", "test-upgrade", "1.1.0" );
>         km = createAndDeployJar( ks, releaseId2, drl1, drl2_2 );
>         // try to update the container to version 1.1.0
>         kc.updateToVersion( releaseId2 );
>         
>         ksession.setGlobal("foo", "bar");
>         // continue working with the session
>         ksession.insert( new Message( "Hello World" ) );
>         assertEquals( 3, ksession.fireAllRules() );
>     }
> {code}
> When I run this unit test, I get the following exception:
> {code}
> java.lang.RuntimeException: Unexpected global [foo]
> 	at org.drools.core.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessionImpl.java:1089)
> 	at org.drools.compiler.integrationtests.IncrementalCompilationTest.testKJarUpgradeSameSessionAddingGlobal(IncrementalCompilationTest.java:239)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> {code}



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the jboss-jira mailing list