Skip to content

Updating shared marker map should be synchronized #137

Description

@tpwalke2

Concurrent, unsynchronized mutation of a shared BlueMap marker map
src/main/java/com/tpwalke2/bluemapsignmarkers/core/bluemap/BlueMapAPIConnector.javaaddMarker (132-154),
updateMarker (114-125), removeMarker (127-130) vs. getMarkerSets (175-207, synchronized)
getMarkerSets(...) is synchronized, but addMarker/updateMarker/removeMarker — which mutate the
Map<String, Marker> returned by MarkerSet.getMarkers() — are static and not synchronized on anything.
ReactiveQueue's executor is sized to availableProcessors(), so on any multi-core host more than one
MarkerAction can be dispatched to processMarkerAction concurrently. Two actions targeting different sign
positions on the same map + marker group resolve to the same cached MarkerSet and thus the same underlying marker
Map instance (whose concrete thread-safety is controlled by BlueMap's API, not this mod). Concurrent
put/remove/iteration on that map risks lost updates or corruption during a resize. getMarkerSets's
synchronized only protects lookup/creation of the list reference, not what happens to its contents afterward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions