Bug 734762

Summary: NPE when disposing already disposed StatefulKnowledgeSession
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Tomas Schlosser <tschloss>
Component: BRE (Expert, Fusion)Assignee: Nobody <nobody>
Status: VERIFIED --- QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: BRMS 5.2.0.GACC: mproctor
Target Milestone: ---   
Target Release: BRMS 5.3.0.GA   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
A Null Pointer Exception was thrown when calling StatefulKnowledgeSession.dispose() on already disposed session. The issue has been resolved, calling any session's method after disposing the session now raises an IllegalStateException.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 729915    
Bug Blocks:    

Description Tomas Schlosser 2011-08-31 11:26:57 UTC
Description of problem:
When a StatefulKnowledgeSession.dispose() is called on already disposed session NullPointerException is thrown.

Version-Release number of selected component (if applicable):
BRMS-5.2.0-ER3

How reproducible:
every time

Steps to Reproduce:
1. create new stateful session
2. dispose it
3. dispose it again
  
Actual results:
java.lang.NullPointerException
	at org.jbpm.process.instance.ProcessRuntimeImpl.dispose(ProcessRuntimeImpl.java:371)
	at org.drools.common.AbstractWorkingMemory.dispose(AbstractWorkingMemory.java:1251)
	at org.drools.reteoo.ReteooStatefulSession.dispose(ReteooStatefulSession.java:179)
	at org.drools.impl.StatefulKnowledgeSessionImpl.dispose(StatefulKnowledgeSessionImpl.java:251)
	at org.jboss.qa.drools.disposeNPE.DisposeNPETest$Test.run(DisposeNPETest.java:51)
	at org.jboss.qa.drools.disposeNPE.DisposeNPETest.main(DisposeNPETest.java:35)

Expected results:


Additional info:
This is caused by users using dispose() as a way to clean the state of the session. I suppose that when session is disposed it should be unusable but in case of using it an understandable exception should be thrown (like AlreadyDisposedException). And the documentation should clearly state that disposed sessions are not to be used.

Comment 2 JBoss JIRA Server 2012-01-19 20:58:38 UTC
Edson Tirelli <ed.tirelli> updated the status of jira JBRULES-1880 to Resolved

Comment 3 JBoss JIRA Server 2012-01-19 20:58:38 UTC
Edson Tirelli <ed.tirelli> made a comment on jira JBRULES-1880

Fixed. Calling any session's method after disposing the session will now raise an IllegalStateException.

Comment 4 JBoss JIRA Server 2012-01-19 20:58:45 UTC
Edson Tirelli <ed.tirelli> updated the status of jira JBRULES-1880 to Closed

Comment 6 Tomas Schlosser 2012-01-30 14:29:07 UTC
It is fixed now. Thank you

Comment 7 lcarlon 2012-05-03 02:20:19 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
A Null Pointer Exception was thrown when calling StatefulKnowledgeSession.dispose() on already disposed session. The issue has been resolved, calling any session's method after disposing the session now raises
an IllegalStateException.