Permalink
Browse files

MAS-core : improve disposal routine to prevent leaks

  • Loading branch information...
1 parent 125b0db commit 87f524ba589d9f897e841f03a5dd501c63b54fdf @sotty sotty committed Aug 5, 2012
Showing with 13 additions and 6 deletions.
  1. +13 −6 drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgent.java
@@ -120,15 +120,22 @@ public void dispose() {
GridServiceDescription<GridNode> nGsd = null;
if ( node == null ) {
nGsd = grid.get( WhitePages.class ).lookup( sessionLoc.getNodeId() );
+ if ( nGsd != null ) {
GridConnection<GridNode> conn = grid.get( ConnectionFactoryService.class ).createConnection( nGsd );
- node = conn.connect();
-
- StatefulKnowledgeSession ksession = node.get( sessionLoc.getSessionId(), StatefulKnowledgeSession.class );
- ksession.dispose();
- node.dispose();
-
+ node = conn.connect();
+ if ( logger.isDebugEnabled() ) {
+ logger.debug(" ### \t Session " + sessionLoc + " found in " + node.getId() + " >> local = " + node.isRemote() + " ( proxy = " + node.isRemote() + " ) " );
+ }
+
+ StatefulKnowledgeSession ksession = node.get( sessionLoc.getSessionId(), StatefulKnowledgeSession.class );
+ ksession.dispose();
+ }
} else {
// it's a local node ( triple check! ), so we just shut the KS down. The node will be disposed later
+ if ( logger.isDebugEnabled() ) {
+ logger.debug(" ### \t Session " + sessionLoc + " found in " + node.getId() + " >> local = " + node.isRemote() + " ( proxy = " + node.isRemote() + " ) " );
+ }
+
StatefulKnowledgeSession ksession = node.get( sessionLoc.getSessionId(), StatefulKnowledgeSession.class );
ksession.dispose();
}

0 comments on commit 87f524b

Please sign in to comment.