Skip to content

Commit

Permalink
ISPN-8548 Clear post notifications can cause memory issues as it holds
Browse files Browse the repository at this point in the history
all entries locally
  • Loading branch information
wburns committed Nov 21, 2017
1 parent d5ff235 commit ef05bfd
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.infinispan.commands.FlagAffectedCommand;
Expand Down Expand Up @@ -186,10 +187,12 @@ public final void commitEntry(CacheEntry entry, FlagAffectedCommand command, Inv

private void commitClearCommand(DataContainer<Object, Object> dataContainer, ClearCacheEntry<Object, Object> cacheEntry,
InvocationContext context, FlagAffectedCommand command) {
List<InternalCacheEntry<Object, Object>> copyEntries = new ArrayList<>(dataContainer.sizeIncludingExpired());
dataContainer.iterator().forEachRemaining(copyEntries::add);
cacheEntry.commit(dataContainer);
for (InternalCacheEntry entry : copyEntries) {
Iterator<InternalCacheEntry<Object, Object>> iterator = dataContainer.iterator();

while (iterator.hasNext()) {
InternalCacheEntry entry = iterator.next();
// Iterator doesn't support remove
dataContainer.remove(entry.getKey());
notifier.notifyCacheEntryRemoved(entry.getKey(), entry.getValue(), entry.getMetadata(), false, context, command);
}
}
Expand Down

0 comments on commit ef05bfd

Please sign in to comment.