[jboss-svn-commits] JBL Code SVN: r19819 - labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 1 17:49:31 EDT 2008


Author: mark.proctor at jboss.com
Date: 2008-05-01 17:49:31 -0400 (Thu, 01 May 2008)
New Revision: 19819

Modified:
   labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
Log:
JBRULES-1512 UnsupportedOperationException when calling addPackage on rulebase.
-Package.getGlobals() was returning an EMPTY_MAP, thus putall didn't work. So now just iterating calling addGlobal, which lazilly initialises the HashMap.

Modified: labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-05-01 21:34:47 UTC (rev 19818)
+++ labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-05-01 21:49:31 UTC (rev 19819)
@@ -498,11 +498,15 @@
             final String identifier = (String) it.next();
             final Class type = (Class) globals.get( identifier );
             if ( globals.containsKey( identifier ) && !globals.get( identifier ).equals( type ) ) {
-                throw new PackageIntegrationException( "Unable to merge new Package",
+                throw new PackageIntegrationException( "Unable to merge new Package, because it re-declares a global using a different type.",
                                                        newPkg );
             }
         }
-        globals.putAll( newPkg.getGlobals() );
+        for ( Iterator it = newPkg.getGlobals().entrySet().iterator(); it.hasNext(); ) {
+            Entry entry = ( Entry ) it.next();
+            pkg.addGlobal( (String) entry.getKey(), (Class) entry.getValue() );
+        }
+        
 
         //Add rules into the RuleBase package
         //as this is needed for individual rule removal later on




More information about the jboss-svn-commits mailing list