joerghoh opened a new pull request, #60: URL: https://github.com/apache/sling-org-apache-sling-event/pull/60
## Problem `TopologyCapabilities.roundRobinMap` was a plain `HashMap` that is read-modify-written (`get` → check → `put`) with no synchronization. The single shared `TopologyCapabilities` instance is reached from the public `JobManager.addJob(...)` API via `detectTarget(...)`, which is called concurrently by arbitrary client threads with no lock in between. Under concurrent job submission this causes: - **Lost updates** — two callers read the same index and are routed to the same instance, defeating even distribution across the cluster. - **`HashMap` corruption** — unsynchronized concurrent `put` can corrupt the internal table during resize (wrong/stale lookups, or a spinning lookup). Because this map backs target selection for all topics, the impact is not limited to the racing topic. ## Solution - `roundRobinMap` is now a `ConcurrentHashMap`. - The round-robin counter update is performed as a single atomic `merge(...)`, preserving the previous selection semantics (increment with wraparound at `potentialTargets.size()`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
