SpongePowered / Sponge

The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
MIT License
391 stars 211 forks source link

Custom data failing to load on TileEntitys causes ConcurrentModificationExceptions #2608

Open clienthax opened 4 years ago

clienthax commented 4 years ago

I am currently running

Issue Description Make derp in your plugin that breaks custom data loading properly, Which then breaks the chunk loading with a concurrent modification.

Removing the plugin allows the chunk to load with no issues.

[18:02:32] [Server thread/INFO] [net.minecraft.server.management.PlayerList]: WiseDirector [/97.82.181.45:51652] logged in with entity id [3216] in world (minecraft:overworld/0) at (-1060.2651444698438, 88.0, -1970.699999988079).
[18:02:32] [Server thread/INFO] [EnderCore]: Sending server configs to client for com.enderio.core.common.config.ConfigHandler
[18:02:32] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: WiseDirector joined the game
[18:02:32] [Server thread/WARN] [Sponge]: musicbox: It is no longer required to include the plugin id when specifying a Key id through Key.Builder#id. This is deprecated and may be removed later. The plugin id will be retrieved from the current PluginContainer in the cause stack. Key: musicbox:musicboxtype
[18:02:32] [Server thread/ERROR] [net.minecraft.tileentity.TileEntity]: Failed to load data for block entity minecraft:jukebox
java.lang.ExceptionInInitializerError: null
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsData.registerGettersAndSetters(MusicBoxSettingsData.java:42) ~[MusicBoxSettingsData.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsData.<init>(MusicBoxSettingsData.java:37) ~[MusicBoxSettingsData.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsData.<init>(MusicBoxSettingsData.java:30) ~[MusicBoxSettingsData.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsDataBuilder.create(MusicBoxSettingsDataBuilder.java:20) ~[MusicBoxSettingsDataBuilder.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsDataBuilder.buildContent(MusicBoxSettingsDataBuilder.java:30) ~[MusicBoxSettingsDataBuilder.class:?]
    at org.spongepowered.api.data.persistence.AbstractDataBuilder.build(AbstractDataBuilder.java:87) ~[AbstractDataBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.lambda$deserializeManipulator$11(DataUtil.java:242) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at java.util.Optional.flatMap(Optional.java:241) ~[?:1.8.0_242]
    at org.spongepowered.common.data.util.DataUtil.deserializeManipulator(DataUtil.java:242) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.tryDeserializeManipulator(DataUtil.java:228) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.lambda$deserializeManipulatorList$10(DataUtil.java:210) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_242]
    at org.spongepowered.common.data.util.DataUtil.deserializeManipulatorList(DataUtil.java:210) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.readCustomData(DataUtil.java:562) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at net.minecraft.tileentity.TileEntity.bridge$readFromSpongeCompound(TileEntity.java:3740) ~[avj.class:?]
    at net.minecraft.tileentity.TileEntity.handler$zkl000$impl$ReadSpongeDataFromCompound(TileEntity.java:3730) ~[avj.class:?]
    at net.minecraft.tileentity.TileEntity.readFromNBT(TileEntity.java:65) ~[avj.class:?]
    at net.minecraft.block.BlockJukebox$TileEntityJukebox.readFromNBT(SourceFile:36) ~[arp$a.class:?]
    at net.minecraft.tileentity.TileEntity.create(TileEntity.java:120) [avj.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:495) [aye.class:?]
    at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:101) [ChunkIOProvider.class:?]
    at net.minecraftforge.common.chunkio.ChunkIOExecutor.tick(ChunkIOExecutor.java:150) [ChunkIOExecutor.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:728) [MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:397) [nz.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.lang.IllegalStateException: Couldn't find a PluginContainer in the cause stack.
    at org.spongepowered.common.util.SpongeCatalogBuilder.lambda$build$0(SpongeCatalogBuilder.java:85) ~[SpongeCatalogBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at java.util.Optional.orElseThrow(Optional.java:290) ~[?:1.8.0_242]
    at org.spongepowered.common.util.SpongeCatalogBuilder.build(SpongeCatalogBuilder.java:85) ~[SpongeCatalogBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.SpongeKeyBuilder.build(SpongeKeyBuilder.java:45) ~[SpongeKeyBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxKeys.<clinit>(MusicBoxKeys.java:19) ~[MusicBoxKeys.class:?]
    ... 27 more
[18:02:32] [Server thread/ERROR] [FML]: A TileEntity minecraft:jukebox(net.minecraft.block.BlockJukebox$TileEntityJukebox) has thrown an exception during loading, its state cannot be restored. Report this to the mod author
java.lang.ExceptionInInitializerError: null
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsData.registerGettersAndSetters(MusicBoxSettingsData.java:42) ~[MusicBoxSettingsData.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsData.<init>(MusicBoxSettingsData.java:37) ~[MusicBoxSettingsData.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsData.<init>(MusicBoxSettingsData.java:30) ~[MusicBoxSettingsData.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsDataBuilder.create(MusicBoxSettingsDataBuilder.java:20) ~[MusicBoxSettingsDataBuilder.class:?]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxSettingsDataBuilder.buildContent(MusicBoxSettingsDataBuilder.java:30) ~[MusicBoxSettingsDataBuilder.class:?]
    at org.spongepowered.api.data.persistence.AbstractDataBuilder.build(AbstractDataBuilder.java:87) ~[AbstractDataBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.lambda$deserializeManipulator$11(DataUtil.java:242) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at java.util.Optional.flatMap(Optional.java:241) ~[?:1.8.0_242]
    at org.spongepowered.common.data.util.DataUtil.deserializeManipulator(DataUtil.java:242) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.tryDeserializeManipulator(DataUtil.java:228) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.lambda$deserializeManipulatorList$10(DataUtil.java:210) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_242]
    at org.spongepowered.common.data.util.DataUtil.deserializeManipulatorList(DataUtil.java:210) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.util.DataUtil.readCustomData(DataUtil.java:562) ~[DataUtil.class:1.12.2-2838-7.2.2-RC4024]
    at net.minecraft.tileentity.TileEntity.bridge$readFromSpongeCompound(TileEntity.java:3740) ~[avj.class:?]
    at net.minecraft.tileentity.TileEntity.handler$zkl000$impl$ReadSpongeDataFromCompound(TileEntity.java:3730) ~[avj.class:?]
    at net.minecraft.tileentity.TileEntity.readFromNBT(TileEntity.java:65) ~[avj.class:?]
    at net.minecraft.block.BlockJukebox$TileEntityJukebox.readFromNBT(SourceFile:36) ~[arp$a.class:?]
    at net.minecraft.tileentity.TileEntity.create(TileEntity.java:120) [avj.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:495) [aye.class:?]
    at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:101) [ChunkIOProvider.class:?]
    at net.minecraftforge.common.chunkio.ChunkIOExecutor.tick(ChunkIOExecutor.java:150) [ChunkIOExecutor.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:728) [MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:397) [nz.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.lang.IllegalStateException: Couldn't find a PluginContainer in the cause stack.
    at org.spongepowered.common.util.SpongeCatalogBuilder.lambda$build$0(SpongeCatalogBuilder.java:85) ~[SpongeCatalogBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at java.util.Optional.orElseThrow(Optional.java:290) ~[?:1.8.0_242]
    at org.spongepowered.common.util.SpongeCatalogBuilder.build(SpongeCatalogBuilder.java:85) ~[SpongeCatalogBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at org.spongepowered.common.data.SpongeKeyBuilder.build(SpongeKeyBuilder.java:45) ~[SpongeKeyBuilder.class:1.12.2-2838-7.2.2-RC4024]
    at uk.co.haxyshideout.musicbox.data.spongedata.MusicBoxKeys.<clinit>(MusicBoxKeys.java:19) ~[MusicBoxKeys.class:?]
    ... 27 more
[18:02:32] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: Encountered an unexpected exception
java.util.ConcurrentModificationException: null
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445) ~[?:1.8.0_242]
    at java.util.HashMap$ValueIterator.next(HashMap.java:1474) ~[?:1.8.0_242]
    at net.minecraft.world.World.addTileEntities(World.java:1949) ~[amu.class:?]
    at net.minecraft.world.chunk.Chunk.onLoad(Chunk.java:856) ~[axw.class:?]
    at net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:109) ~[ChunkIOProvider.class:?]
    at net.minecraftforge.common.chunkio.ChunkIOExecutor.tick(ChunkIOExecutor.java:150) ~[ChunkIOExecutor.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:728) ~[MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:397) ~[nz.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) ~[MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
[18:02:32] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: This crash report has been saved to: /home/container/./crash-reports/crash-2020-05-12_18.02.32-server.txt
gabizou commented 4 years ago

I'll concede that Sponge should try to avoid causing a failure like this, but custom data should be registered during the DataRegistrationEvent.