Skip to content

Commit 59b3e7d

Browse files
andrews-mocAndrii-Horishnii-Glia
authored andcommitted
Fix ConcurrentModificationException in putOperator(GliaOperatorRepository.kt:52)
Crash log: https://glia.sentry.io/issues/6328957069/
1 parent 29d34dc commit 59b3e7d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

widgetssdk/src/main/java/com/glia/widgets/core/engagement/GliaOperatorRepository.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ internal class GliaOperatorRepositoryImpl(private val gliaCore: GliaCore) : Glia
2525
var isAlwaysUseDefaultOperatorPicture: Boolean = false
2626

2727
override fun getOperatorById(operatorId: String, callback: Consumer<LocalOperator?>) {
28-
val cachedOperator = cachedOperators[operatorId]
28+
val cachedOperator: LocalOperator?
29+
synchronized(cachedOperators) {
30+
cachedOperator = cachedOperators[operatorId]
31+
}
2932
if (cachedOperator != null) {
3033
callback.accept(cachedOperator)
3134
return
@@ -49,7 +52,9 @@ internal class GliaOperatorRepositoryImpl(private val gliaCore: GliaCore) : Glia
4952

5053
@VisibleForTesting
5154
fun putOperator(operator: LocalOperator) {
52-
operator.apply { cachedOperators.put(id, this) }
55+
synchronized(cachedOperators) {
56+
operator.apply { cachedOperators.put(id, this) }
57+
}
5358
}
5459

5560
override fun updateOperatorDefaultImageUrl(imageUrl: String?) {

0 commit comments

Comments
 (0)