Skip to content
Browse files

[DROOLS-72] avoid memory leak when in StatelessSession when fireAll t…

…hrows an Exception
  • Loading branch information...
1 parent 4023efa commit e7326f40018c12bb745d58e2880d7d1143e9787a @mariofusco mariofusco committed Mar 28, 2013
Showing with 13 additions and 9 deletions.
  1. +13 −9 drools-core/src/main/java/org/drools/core/impl/StatelessKnowledgeSessionImpl.java
View
22 drools-core/src/main/java/org/drools/core/impl/StatelessKnowledgeSessionImpl.java
@@ -292,20 +292,24 @@ public Globals getGlobals() {
public void execute(Object object) {
StatefulKnowledgeSession ksession = newWorkingMemory();
-
- ksession.insert( object );
- ksession.fireAllRules( );
- ksession.dispose();
+ try {
+ ksession.insert( object );
+ ksession.fireAllRules( );
+ } finally {
+ ksession.dispose();
+ }
}
public void execute(Iterable objects) {
StatefulKnowledgeSession ksession = newWorkingMemory();
-
- for ( Object object : objects ) {
- ksession.insert( object );
+ try {
+ for ( Object object : objects ) {
+ ksession.insert( object );
+ }
+ ksession.fireAllRules( );
+ } finally {
+ ksession.dispose();
}
- ksession.fireAllRules( );
- ksession.dispose();
}
public Environment getEnvironment() {

0 comments on commit e7326f4

Please sign in to comment.
Something went wrong with that request. Please try again.