Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Revert "Sorting the transformable set to avoid deadlock"
Browse files Browse the repository at this point in the history
This reverts commit 5054663.
  • Loading branch information
fjtirado committed Aug 2, 2023
1 parent 5054663 commit 5b13798
Showing 1 changed file with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -40,26 +39,17 @@ public static void addToUpdatableSet(TransactionManager txm, Transformable trans
if (transformable == null) {
return;
}
Set<Transformable> toBeUpdated = (Set<Transformable>) txm
.getResource(APP_UPDETEABLE_RESOURCE);
Set<Transformable> toBeUpdated = (Set<Transformable>) txm.getResource(APP_UPDETEABLE_RESOURCE);
if (toBeUpdated == null) {

toBeUpdated = new TreeSet<>(new Comparator<Transformable>() {
@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<Transformable>();
txm.putResource(APP_UPDETEABLE_RESOURCE, toBeUpdated);
}
toBeUpdated.add(transformable);
}

@SuppressWarnings("unchecked")
public static void removeFromUpdatableSet(TransactionManager txm, Transformable transformable) {
Set<Transformable> toBeUpdated = (Set<Transformable>) txm
.getResource(APP_UPDETEABLE_RESOURCE);
Set<Transformable> toBeUpdated = (Set<Transformable>) txm.getResource(APP_UPDETEABLE_RESOURCE);
if (toBeUpdated == null) {
return;
}
Expand All @@ -68,11 +58,11 @@ public static void removeFromUpdatableSet(TransactionManager txm, Transformable

@SuppressWarnings("unchecked")
public static Set<Transformable> getUpdateableSet(TransactionManager txm) {
Set<Transformable> toBeUpdated = (Set<Transformable>) txm
.getResource(APP_UPDETEABLE_RESOURCE);
Set<Transformable> toBeUpdated = (Set<Transformable>) txm.getResource(APP_UPDETEABLE_RESOURCE);
if (toBeUpdated == null) {
return Collections.emptySet();
}
return new LinkedHashSet<>(toBeUpdated);

return new LinkedHashSet<Transformable>(toBeUpdated);
}
}

0 comments on commit 5b13798

Please sign in to comment.