MinecraftForge / SrgUtils

A library for working with SRG, and other mapping variants.
GNU Lesser General Public License v2.1
12 stars 16 forks source link

Use ConcurrentHashMap for the caches #7

Closed octylFractal closed 2 years ago

octylFractal commented 2 years ago

These maps are referenced across threads in other places, so the methods should be thread-safe.

This fixes an error in FG where the cache in MappedFile is accessed asynchronously, resulting in the following exception:

Caused by: java.lang.ClassCastException: class java.util.HashMap$Node cannot be cast to class java.util.HashMap$TreeNode (java.util.HashMap$Node and java.util.HashMap$TreeNode are in module java.base of loader 'bootstrap')
LexManos commented 2 years ago

https://github.com/MinecraftForge/SrgUtils/commit/5a55d872510e41a1382ce797193e5e57770ac4f7 Should of solved this, if not see if someone can make a reproduction case.

octylFractal commented 2 years ago

Is that part of the latest ForgeGradle (5.1.26)? If so, I am reproducing this right now locally by importing this branch/PR of WorldEdit. I can setup a smaller reproducer if you like.

LexManos commented 2 years ago

Not a fan of this shotgun approach because reads should be safe. But guess there is a JRE specific implementation issue. Committed myself because I also included reverting the attempted fix.