`IllegalStateException` using `JavaAdapter` for multi-threaded usages like ForgeCap
YukkuriC opened this issue ยท 1 comments
stacktrace:
Description: Ticking block entity
java.lang.IllegalStateException: null
at dev.latvian.mods.rhino.Context.doTopCall(Context.java:1387) ~[rhino-forge-2001.2.3-build.10.jar%23775!/:2001.2.3-build.10] {re:classloading}
at dev.latvian.mods.rhino.InterpretedFunction.call(InterpretedFunction.java:70) ~[rhino-forge-2001.2.3-build.10.jar%23775!/:2001.2.3-build.10] {re:classloading}
at dev.latvian.mods.rhino.JavaAdapter.callMethod(JavaAdapter.java:460) ~[rhino-forge-2001.2.3-build.10.jar%23775!/:2001.2.3-build.10] {re:classloading}
at adapter3.receiveEnergy(<adapter>) ~[?:?] {}
at blusunrize.immersiveengineering.common.blocks.metal.EnergyConnectorBlockEntity.tickServer(EnergyConnectorBlockEntity.java:129) ~[ImmersiveEngineering-1.20.1-10.2.0-183.jar%23687!/:?] {re:classloading}
...
related code: https://github.com/YukkuriC/kubejs_playground/blob/c2bf84cfd2d31d7643e2d5895587519ec696cbe1/startup_scripts/goety/mana_trans.js#L64
in which I added an energy cap to a block entity
this happens randomly, also observed on other heavy usages like replacing an RNG with a wrapped adapter one
wandering if it's safe to make Context.doTopCall synchronized
no, not this way, got a immediate dead lock
[16:52:29] [ModernFix integrated server watchdog/ERROR]: Thread Dump:
"Render thread" prio=10 Id=1 BLOCKED on dev.latvian.mods.rhino.Context@4aeff698 owned by "Server thread" Id=284
at TRANSFORMER/[email protected]/dev.latvian.mods.rhino.Context.doTopCall(Context.java:1362)
- blocked on dev.latvian.mods.rhino.Context@4aeff698
at TRANSFORMER/[email protected]/dev.latvian.mods.rhino.InterpretedFunction.call(InterpretedFunction.java:70)
at TRANSFORMER/[email protected]/dev.latvian.mods.rhino.Context.callSync(Context.java:1357)
- locked java.lang.Object@2905ea3d
at TRANSFORMER/[email protected]/dev.latvian.mods.rhino.ArrowFunction.call(ArrowFunction.java:42)
at TRANSFORMER/[email protected]/dev.latvian.mods.rhino.Context.callSync(Context.java:1357)
- locked java.lang.Object@2905ea3d
at TRANSFORMER/[email protected]/dev.latvian.mods.rhino.InterfaceAdapter.invoke(InterfaceAdapter.java:125)