Skip to content

Server-rest: serialise endpoint route registration in MajordomoRestPlugin - #274

Open
t0susnik wants to merge 1 commit into
fair-acc:mainfrom
t0susnik:fix/rest-plugin-endpoint-registration-race
Open

Server-rest: serialise endpoint route registration in MajordomoRestPlugin#274
t0susnik wants to merge 1 commit into
fair-acc:mainfrom
t0susnik:fix/rest-plugin-endpoint-registration-race

Conversation

@t0susnik

@t0susnik t0susnik commented Aug 13, 2026

Copy link
Copy Markdown

Fixes #275

Fixing a race condition in MajordomoRestPlugin.registerEndPoint() that caused
MajordomoRestPluginTests to fail randomly in CI with:
ConcurrentModificationException / IllegalArgumentException: already exists

The fix protects concurrent endpoint registration against the same Javalin instance,
be it from different threads within one REST plugin or from multiple REST plugin
instances sharing the same JVM-wide RestServer.getInstance().

Verified: reliably reproduced within ~10 runs before the fix, 0 recurrences in 8 runs after.

@t0susnik t0susnik changed the title erver-rest: serialise endpoint route registration in MajordomoRestPlugin Server-rest: serialise endpoint route registration in MajordomoRestPlugin Aug 13, 2026
…ugin

In registerEndPoint() registeredEndpoints.computeIfAbsent() only
de-duplicates the same endpoint key; it does not serialise different
endpoints against each other. start() registers endpoints from two
independent threads (the initial synchronous enumeration and the async
service-subscription listener), both mutating Javalin's shared,
non-thread-safe route table.
This caused a ConcurrentModificationException / IllegalArgumentException
race.

Signed-off-by: Tomaž Sušnik <tomaz.susnik@cosylab.com>
@t0susnik
t0susnik force-pushed the fix/rest-plugin-endpoint-registration-race branch from 28a0526 to bbdb8d6 Compare August 13, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in MajordomoRestPlugin.registerEndPoint() causes intermittent CI failures in MajordomoRestPluginTests

2 participants