Hide Forgot
The implementation of the improvement described here https://issues.jboss.org/browse/DROOLS-1110 caused a race condition because a ksession could be disposed and removed from the kbase's sessions list while another thread is iterating. When this happens the following exception is thrown: Exception in thread "Thread-28" java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) at java.util.HashMap$KeyIterator.next(HashMap.java:1453) at org.drools.core.impl.KnowledgeBaseImpl.tryDeactivateAllSessions(KnowledgeBaseImpl.java:756) at org.drools.core.impl.KnowledgeBaseImpl.tryLockAndDeactivate(KnowledgeBaseImpl.java:777) at org.drools.core.impl.KnowledgeBaseImpl.enqueueModification(KnowledgeBaseImpl.java:714) at org.drools.compiler.kie.builder.impl.KieContainerImpl.update(KieContainerImpl.java:184) at org.drools.compiler.kie.builder.impl.KieContainerImpl.updateToVersion(KieContainerImpl.java:131) at org.drools.compiler.integrationtests.KieContainerTest$1.run(KieContainerTest.java:202) at java.lang.Thread.run(Thread.java:745)
Fixed on master by https://github.com/droolsjbpm/drools/commit/f8e96ef7cf8070f4ceac941b7727c9dcf3455322
Cherry-picked to 6.4.x by https://github.com/droolsjbpm/drools/commit/1d91b8dd5
It seems that the ConcurrentModificationException can still appear if you iterate the list of KieSessions obtained from KieBase.getKieSessions() and dispose them, for instance: for (KieSession kieSession : kieBase.getKieSessions()) { kieSession.dispose(); } Please see PR with test: https://github.com/droolsjbpm/drools/pull/761 This used to work in BxMS 6.3.0 ER1 (probably before DROOLS-1110). There is also a workaround by copying the KieSessions collection before iterating it, such as: Collection<KieSession> kieSessions = new ArrayList<KieSession>(); kieSessions.addAll(this.kieBase.getKieSessions()); for (KieSession kieSession : kieSessions) { kieSession.dispose(); } Is this change in behavior expected for 6.3 product? (If so, we must document it.)
Fixed on master by https://github.com/droolsjbpm/drools/compare/8eadcaa...a62d5e9
Cherry-picked to 6.4.x branch with https://github.com/droolsjbpm/drools/compare/58ddfd1...a1f989f