From 5b13798ed4d265c580de5c243d65d602aeea3ebd Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 2 Aug 2023 22:41:51 +0200 Subject: [PATCH] Revert "Sorting the transformable set to avoid deadlock" This reverts commit 50546632e6ecac22e19cf7fd72002ba47a2243bb. --- .../api/TransactionManagerHelper.java | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java b/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java index e30badf981b..adf917317dc 100644 --- a/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java +++ b/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java @@ -16,14 +16,13 @@ package org.drools.persistence.api; import java.util.Collections; -import java.util.Comparator; import java.util.LinkedHashSet; import java.util.Set; -import java.util.TreeSet; public class TransactionManagerHelper { private static final String APP_UPDETEABLE_RESOURCE = "app-updateable-resource"; + private static final String CMD_UPDETEABLE_RESOURCE = "cmd-updateable-resource"; public static void registerTransactionSyncInContainer(TransactionManager txm, OrderedTransactionSynchronization synchronization) { TransactionSynchronizationContainer container = (TransactionSynchronizationContainer)txm.getResource(TransactionSynchronizationContainer.RESOURCE_KEY); @@ -40,17 +39,9 @@ public static void addToUpdatableSet(TransactionManager txm, Transformable trans if (transformable == null) { return; } - Set toBeUpdated = (Set) txm - .getResource(APP_UPDETEABLE_RESOURCE); + Set toBeUpdated = (Set) txm.getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { - - toBeUpdated = new TreeSet<>(new Comparator() { - @Override - public int compare(Transformable o1, Transformable o2) { - int result = o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName()); - return result == 0 ? -1 : result; - } - }); + toBeUpdated = new LinkedHashSet(); txm.putResource(APP_UPDETEABLE_RESOURCE, toBeUpdated); } toBeUpdated.add(transformable); @@ -58,8 +49,7 @@ public int compare(Transformable o1, Transformable o2) { @SuppressWarnings("unchecked") public static void removeFromUpdatableSet(TransactionManager txm, Transformable transformable) { - Set toBeUpdated = (Set) txm - .getResource(APP_UPDETEABLE_RESOURCE); + Set toBeUpdated = (Set) txm.getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { return; } @@ -68,11 +58,11 @@ public static void removeFromUpdatableSet(TransactionManager txm, Transformable @SuppressWarnings("unchecked") public static Set getUpdateableSet(TransactionManager txm) { - Set toBeUpdated = (Set) txm - .getResource(APP_UPDETEABLE_RESOURCE); + Set toBeUpdated = (Set) txm.getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { return Collections.emptySet(); } - return new LinkedHashSet<>(toBeUpdated); + + return new LinkedHashSet(toBeUpdated); } }