ReactiveCircus/cache4k

ConcurrentModificationException will be reported when concurrent

Jude95 opened this issue ยท 9 comments

java.util.ConcurrentModificationException
        java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:756)
        java.base/java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:778)
        io.github.reactivecircus.cache4k.RealCache.expireEntries(RealCache.kt:174)
        io.github.reactivecircus.cache4k.RealCache.put(RealCache.kt:120)

+1:

java.util.ConcurrentModificationException at 
java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:760) at
java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:782) at
kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:272) at
io.github.reactivecircus.cache4k.RealCache.evictEntries(RealCache.kt:206) at
io.github.reactivecircus.cache4k.RealCache.put(RealCache.kt:140)

I think we need to revert back to using stately which is thread-safe on JVM.

@ychescale9 will you be making a release anytime soon ?

I'll try to find some time in the coming weeks.

So I'm having issues with cache4k and ConcurrentModificationExceptions caused by stately on jvm.

Ktor's io.ktor.util.collections.ConcurrentMap seems to be stable, maybe their implementation could be used instead?

Thanks, will look into it.

+1 for Ktor Utils Collections ๐Ÿ˜Š

looks like ktor's ConcurrentMap just delegates to ConcurrentHashMap on JVM which I've done in #39, though there are still some linearizability issues surfaced by Lincheck. Maybe we can land that change now and deal with the remaining issues later as they are not regressions.

Just released 0.13.0 with ConcurrentHashMap on JVM. Please let me know if this fixes the issue.