Skip to content

ConcurrentModificationException in MobsLayer causes mob marker layer to repeatedly fail #32

@SebzIO

Description

@SebzIO

Spark link

No response

Plugin Version

1.5.0

Server Version

Paper 26.1.2-52

Server Platform

Paper

Describe the bug

Bug Report

Description

The mob markers layer fails repeatedly with a ConcurrentModificationException.
This happens because MobsLayer.getMarkers() iterates over a HashMap while the
server thread is simultaneously modifying it. The error is non-fatal but the mob
layer on the web map fails to update every time it occurs.

Environment

  • Pl3xMapExtras version: 1.5.0
  • Pl3xMap version: 26.1.2-545
  • Server software: Paper 26.1.2-52

Error Log

[Pl3xMap-Markers/INFO]: [Pl3xMap] [ERROR] Failed to process layer pl3xmap_mobs for world world
[Pl3xMap-Markers/WARN]: java.util.ConcurrentModificationException
at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1606)
at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1629)
at java.base/java.util.AbstractCollection.addAll(AbstractCollection.java:337)
at Pl3xMapExtras-1.5.0.jar//com.ryderbelserion.map.marker.mobs.MobsLayer.lambda$getMarkers$0(MobsLayer.java:47)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at Pl3xMapExtras-1.5.0.jar//com.ryderbelserion.map.marker.mobs.MobsLayer.getMarkers(MobsLayer.java:47)
at Pl3xMap-26.1.2-545.jar//net.pl3x.map.core.renderer.task.UpdateMarkerData.lambda$parse$0(UpdateMarkerData.java:56)
at java.base/java.util.concurrent.ConcurrentHashMap$EntrySetView.forEach(ConcurrentHashMap.java:4892)

Root Cause

MobsLayer.java line 47 calls addAll() on what appears to be a plain HashMap,
which is not thread-safe. The Pl3xMap marker update task runs on a separate thread
via CompletableFuture/ForkJoinPool, so it races with the server thread that
modifies the mob collection.

Suggested Fix

Replace the underlying map/collection used in MobsLayer with a thread-safe
alternative such as ConcurrentHashMap, or wrap the iteration in a synchronized
block to prevent concurrent access.

Impact

  • The mob marker layer silently fails to update on every occurrence
  • The error repeats on a regular interval throughout the server's uptime
  • No server crash or player-facing impact, but the web map mob layer is effectively broken

Steps to reproduce

Steps to Reproduce

No specific action required. Occurs automatically on a recurring basis during
normal server operation, particularly when there is mob activity in the world.

Additional context

No response

Agreements

  • I have searched for and ensured there isn't already an open issue regarding this.
  • I ticked all the boxes without actually reading them
  • My version of Minecraft is supported.

Metadata

Metadata

Labels

type: bugSomething doesn't work as it was intended to.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions