+++ This bug was initially created as a clone of Bug #1185691 +++ Description of problem: If session.execute is called concurrently, NullpinterException or IllegalStateExeition occurs. Steps to Reproduce: 1. Download and import Drools6ReoccurNPEProject.zip to JBDS 2. Fix jars and JVM option(like: -Xms1303m -Xmx1303m) 3. Run com.sample.DroolsTest Actual results: One of following types of Exception occurs. === java.lang.IllegalMonitorStateException at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:155) at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1260) at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:460) at org.drools.core.common.AbstractWorkingMemory.endBatchExecution(AbstractWorkingMemory.java:1753) at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:381) at com.sample.RuleTestThread.execRun(RuleTestThread.java:39) at com.sample.RuleTestThread.run(RuleTestThread.java:23) === === java.lang.NullPointerException at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:381) at com.sample.RuleTestThread.execRun(RuleTestThread.java:39) at com.sample.RuleTestThread.run(RuleTestThread.java:23) === Expected results: The program can run without any Exception Additional info: Our customer shares fixed StatelessKnowledgeSessionImpl.java which is the one in BRMS 6.0.3. Please check their modification. The fixed class is attached as StatelessKnowledgeSessionImpl.CHAGEDraft.java
Created attachment 994314 [details] reproducer
Backported to 6.0.x with https://github.com/droolsjbpm/drools/commit/532bdd988
Verified in BRMS 6.0.3 Roll-Up Patch #3.