Leave a tombstone after the deletion of a cache entry
This captures the scenario of multiple deletion calls in the current session. Closes #28672 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
parent
6853dca002
commit
004f419fd0
1 changed files with 19 additions and 1 deletions
|
@ -36,6 +36,21 @@ public class InfinispanKeycloakTransaction implements KeycloakTransaction {
|
||||||
|
|
||||||
private final static Logger log = Logger.getLogger(InfinispanKeycloakTransaction.class);
|
private final static Logger log = Logger.getLogger(InfinispanKeycloakTransaction.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tombstone to mark an entry as already removed for the current session.
|
||||||
|
*/
|
||||||
|
private static final CacheTask TOMBSTONE = new CacheTask() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Tombstone after removal";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public enum CacheOperation {
|
public enum CacheOperation {
|
||||||
ADD, ADD_WITH_LIFESPAN, REMOVE, REPLACE, ADD_IF_ABSENT // ADD_IF_ABSENT throws an exception if there is existing value
|
ADD, ADD_WITH_LIFESPAN, REMOVE, REPLACE, ADD_IF_ABSENT // ADD_IF_ABSENT throws an exception if there is existing value
|
||||||
}
|
}
|
||||||
|
@ -205,7 +220,10 @@ public class InfinispanKeycloakTransaction implements KeycloakTransaction {
|
||||||
CacheTask current = tasks.get(taskKey);
|
CacheTask current = tasks.get(taskKey);
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
if (current instanceof CacheTaskWithValue && ((CacheTaskWithValue<?>) current).getOperation() == Operation.PUT) {
|
if (current instanceof CacheTaskWithValue && ((CacheTaskWithValue<?>) current).getOperation() == Operation.PUT) {
|
||||||
tasks.remove(taskKey);
|
tasks.put(taskKey, TOMBSTONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (current == TOMBSTONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue