From 47817b55589855c09210f7df976dd9e877acc2c7 Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Mon, 12 Aug 2024 14:40:37 +0200 Subject: [PATCH] [Fix] Prevent ConcurrentModificationException in ScheduledContextRemover. The exception was likely caused by adding to the collection while it was being iterated during context removal. --- .../termit/persistence/dao/util/ScheduledContextRemover.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cz/cvut/kbss/termit/persistence/dao/util/ScheduledContextRemover.java b/src/main/java/cz/cvut/kbss/termit/persistence/dao/util/ScheduledContextRemover.java index fb82b4228..326fe0ab0 100644 --- a/src/main/java/cz/cvut/kbss/termit/persistence/dao/util/ScheduledContextRemover.java +++ b/src/main/java/cz/cvut/kbss/termit/persistence/dao/util/ScheduledContextRemover.java @@ -54,7 +54,7 @@ public synchronized void scheduleForRemoval(@NonNull URI contextUri) { */ @Transactional @Scheduled(fixedRate = 1, timeUnit = TimeUnit.MINUTES) - public void runContextRemoval() { + public synchronized void runContextRemoval() { LOG.trace("Running scheduled repository context removal."); contextsToRemove.forEach(g -> { LOG.trace("Dropping repository context {}.", Utils.uriToString(g));