From fb6291792dd86a700c6a88e75db26c1d7427d69c Mon Sep 17 00:00:00 2001 From: Hannes Braun Date: Thu, 14 Oct 2021 00:32:28 +0200 Subject: [PATCH] Use ConcurrentHashMap for timetableList Multiple requests may be processed at the same time and could otherwise cause problems (concurrent write operations) --- .../org/mosad/thecitadelofricks/controller/CacheController.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/mosad/thecitadelofricks/controller/CacheController.kt b/src/main/kotlin/org/mosad/thecitadelofricks/controller/CacheController.kt index 879098b..e95c481 100644 --- a/src/main/kotlin/org/mosad/thecitadelofricks/controller/CacheController.kt +++ b/src/main/kotlin/org/mosad/thecitadelofricks/controller/CacheController.kt @@ -33,9 +33,9 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import java.io.* import java.util.* +import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.Executors import kotlin.collections.ArrayList -import kotlin.collections.HashMap import kotlin.collections.HashSet import kotlin.concurrent.scheduleAtFixedRate import kotlin.time.Duration @@ -53,7 +53,7 @@ class CacheController { var courseList = CoursesList(CoursesMeta(), sortedMapOf()) var mensaMenu = MensaMenu(MensaMeta(0, ""), MensaWeek(), MensaWeek()) - var timetableList = HashMap() // this list contains all timetables + var timetableList = ConcurrentHashMap() // this list contains all timetables /** * get a timetable, since they may not be cached, we need to make sure it's cached, otherwise download