diff --git a/drools-core/src/main/java/org/drools/core/common/EqualityObjectStore.java b/drools-core/src/main/java/org/drools/core/common/EqualityObjectStore.java deleted file mode 100644 index e6c74d89dbc..00000000000 --- a/drools-core/src/main/java/org/drools/core/common/EqualityObjectStore.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023. Red Hat, Inc. and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.drools.core.common; - -import java.util.HashMap; - -public class EqualityObjectStore extends MapObjectStore { - - public EqualityObjectStore() { - super(new HashMap<>()); - } - -} diff --git a/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/SimpleSerializationReliableObjectStore.java b/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/SimpleSerializationReliableObjectStore.java index 355256a5533..f8e9a4921fb 100644 --- a/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/SimpleSerializationReliableObjectStore.java +++ b/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/SimpleSerializationReliableObjectStore.java @@ -21,13 +21,13 @@ import org.drools.core.ClockType; import org.drools.core.common.DefaultEventHandle; -import org.drools.core.common.EqualityObjectStore; +import org.drools.core.common.IdentityObjectStore; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.InternalWorkingMemoryEntryPoint; import org.drools.core.common.Storage; -public class SimpleSerializationReliableObjectStore extends EqualityObjectStore implements SimpleReliableObjectStore { +public class SimpleSerializationReliableObjectStore extends IdentityObjectStore implements SimpleReliableObjectStore { protected final transient Storage storage; diff --git a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityCepTimedOutTest.java b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityCepTimedOutTest.java index 7a7173e741d..4678f1bd373 100644 --- a/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityCepTimedOutTest.java +++ b/drools-reliability/drools-reliability-infinispan/src/test/java/org/drools/reliability/infinispan/ReliabilityCepTimedOutTest.java @@ -50,6 +50,8 @@ import static org.drools.model.PatternDSL.rule; import static org.drools.model.PrototypeDSL.protoPattern; import static org.drools.model.PrototypeDSL.variable; +import static org.drools.model.PrototypeExpression.prototypeField; +import static org.drools.model.PrototypeExpression.thisPrototype; import static org.drools.modelcompiler.facttemplate.FactFactory.createMapBasedEvent; import static org.drools.reliability.infinispan.util.PrototypeUtils.DEFAULT_PROTOTYPE_NAME; import static org.drools.reliability.infinispan.util.PrototypeUtils.SYNTHETIC_PROTOTYPE_NAME; @@ -70,6 +72,7 @@ private Model ruleModel() { PrototypeVariable controlVar1 = variable(controlPrototype, "c1"); PrototypeVariable controlVar2 = variable(controlPrototype, "c2"); PrototypeVariable controlVar3 = variable(controlPrototype, "c3"); + PrototypeVariable eventVar = variable(getPrototype(DEFAULT_PROTOTYPE_NAME), "e"); Variable resultCount = declarationOf( Long.class, "count" ); Global global = globalOf(List.class, "defaultpkg", "results"); @@ -199,9 +202,10 @@ private Model ruleModel() { .build( protoPattern(controlVar1).expr( "rulename", Index.ConstraintType.EQUAL, endTag ), protoPattern(controlVar2).expr(p -> ((String)p.get("rulename")).startsWith(rulePrefix)), - on(controlVar1, controlVar2).execute((drools, c1, c2) -> { - drools.delete(c2.get("event")); - drools.delete(c2); + protoPattern(eventVar).expr( thisPrototype(), Index.ConstraintType.EQUAL, controlVar2, prototypeField("event") ), + on(controlVar2, eventVar).execute((drools, c, e) -> { + drools.delete(e); + drools.delete(c); }) ) ); @@ -215,8 +219,9 @@ private Model ruleModel() { .expr( "rulename", Index.ConstraintType.EQUAL, endTag ) .expr( after(0, timeAmount.getTimeUnit(), timeAmount.getAmount(), timeAmount.getTimeUnit()), controlVar1 ) ), protoPattern(controlVar3).expr(p -> ((String)p.get("rulename")).startsWith(rulePrefix)), - on(controlVar1, controlVar3).execute((drools, c1, c3) -> { - drools.delete(c3.get("event")); + protoPattern(eventVar).expr( thisPrototype(), Index.ConstraintType.EQUAL, controlVar3, prototypeField("event") ), + on(controlVar1, controlVar3, eventVar).execute((drools, c1, c3, e) -> { + drools.delete(e); drools.delete(c3); drools.delete(c1); }) @@ -261,6 +266,9 @@ void insertFailoverExpireFire_shouldFire(PersistedSessionOption.PersistenceStrat assertThat(getResults()).as("after 5 minutes window. the main rule is fired") .hasSize(1); + + assertThat(getFactHandles()).as("All events should be cleaned up") + .isEmpty(); } @ParameterizedTest @@ -287,5 +295,8 @@ void insertExpireFailoverFire_shouldFire(PersistedSessionOption.PersistenceStrat assertThat(getResults()).as("after 5 minutes window. the main rule is fired") .hasSize(1); + + assertThat(getFactHandles()).as("All events should be cleaned up") + .isEmpty(); } }