diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java index 7b713f17a02..fa0cbfe425f 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java @@ -210,7 +210,7 @@ public void setWorkingMemory(final InternalWorkingMemory workingMemory) { this.workingMemory = workingMemory; this.agendaGroupsManager.setReteEvaluator( workingMemory ); - if (!workingMemory.getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe()) { + if (!workingMemory.isThreadSafe()) { executionStateMachine = new UnsafeExecutionStateMachine(); } @@ -219,7 +219,7 @@ public void setWorkingMemory(final InternalWorkingMemory workingMemory) { } protected PropagationList createPropagationList() { - if (!workingMemory.getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe()) { + if (!workingMemory.isThreadSafe()) { return new ThreadUnsafePropagationList( workingMemory ); } diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/entrypoints/NamedEntryPoint.java b/drools-kiesession/src/main/java/org/drools/kiesession/entrypoints/NamedEntryPoint.java index e98a5524cce..ce8a51e67ab 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/entrypoints/NamedEntryPoint.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/entrypoints/NamedEntryPoint.java @@ -48,7 +48,6 @@ import org.drools.core.util.bitmask.AllSetBitMask; import org.drools.core.util.bitmask.BitMask; import org.kie.api.conf.KieBaseMutabilityOption; -import org.kie.api.runtime.conf.ThreadSafeOption; import org.kie.api.runtime.rule.FactHandle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -108,7 +107,7 @@ public NamedEntryPoint(EntryPointId entryPoint, this.entryPointNode = entryPointNode; this.reteEvaluator = reteEvaluator; this.ruleBase = this.reteEvaluator.getKnowledgeBase(); - this.lock = reteEvaluator.getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe() ? new ReentrantLock() : null; + this.lock = reteEvaluator.isThreadSafe() ? new ReentrantLock() : null; this.handleFactory = this.reteEvaluator.getFactHandleFactory(); RuleBaseConfiguration conf = this.ruleBase.getRuleBaseConfiguration(); diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/session/StatefulKnowledgeSessionImpl.java b/drools-kiesession/src/main/java/org/drools/kiesession/session/StatefulKnowledgeSessionImpl.java index 20225854cba..1c97f9cdfcc 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/session/StatefulKnowledgeSessionImpl.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/session/StatefulKnowledgeSessionImpl.java @@ -324,6 +324,9 @@ private StatefulKnowledgeSessionImpl(final long id, this.propagationIdCounter = new AtomicLong(propagationContext); this.config = config; this.ruleSessionConfig = config.as(RuleSessionConfiguration.KEY); + + isThreadSafe = ruleSessionConfig.getOption(ThreadSafeOption.KEY).isThreadSafe(); + this.environment = environment; this.propagationIdCounter = new AtomicLong( propagationContext); @@ -352,7 +355,6 @@ private StatefulKnowledgeSessionImpl(final long id, this.initialFactHandle = initInitialFact(null); } - isThreadSafe = getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe(); } public StatefulKnowledgeSessionImpl setStateless( boolean stateless ) { @@ -1517,7 +1519,7 @@ public long getTotalFactCount() { */ @Override public void startOperation(InternalOperationType operationType) { - if (getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe() && this.opCounter.getAndIncrement() == 0 ) { + if (isThreadSafe() && this.opCounter.getAndIncrement() == 0 ) { // means the engine was idle, reset the timestamp this.lastIdleTimestamp.set(-1); } @@ -1539,7 +1541,7 @@ public void setEndOperationListener(EndOperationListener listener) { */ @Override public void endOperation(InternalOperationType operationType) { - if (getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe() && this.opCounter.decrementAndGet() == 0 ) { + if (isThreadSafe() && this.opCounter.decrementAndGet() == 0 ) { // means the engine is idle, so, set the timestamp if (this.timerService != null) { this.lastIdleTimestamp.set(this.timerService.getCurrentTime()); diff --git a/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/consequence/LambdaConsequence.java b/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/consequence/LambdaConsequence.java index 16e5e5e010c..f97cccd8da2 100644 --- a/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/consequence/LambdaConsequence.java +++ b/drools-model/drools-model-compiler/src/main/java/org/drools/modelcompiler/consequence/LambdaConsequence.java @@ -125,7 +125,7 @@ private Object[] fetchFacts( KnowledgeHelper knowledgeHelper, ValueResolver valu Object[] facts; FactHandleLookup fhLookup = null; - if (reteEvaluator.getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe()) { + if (reteEvaluator.isThreadSafe()) { if ( consequence.isUsingDrools() ) { facts = new Object[consequence.getVariables().length + 1]; fhLookup = FactHandleLookup.create( factSuppliers.length ); @@ -217,7 +217,7 @@ private Object[] initConsequence( KnowledgeHelper knowledgeHelper, ReteEvaluator this.globalSuppliers = globalSuppliers.isEmpty() ? null : globalSuppliers.toArray( new GlobalSupplier[globalSuppliers.size()] ); this.factSuppliers = factSuppliers.toArray( new TupleFactSupplier[factSuppliers.size()] ); - if (!reteEvaluator.getRuleSessionConfiguration().getOption(ThreadSafeOption.KEY).isThreadSafe()) { + if (!reteEvaluator.isThreadSafe()) { this.facts = facts; this.fhLookup = fhLookup; }