Skip to content

Race Condition in ScenarioEndpoint Due to LIFO Stack #334

@tschlat

Description

@tschlat

As pointed out by @bbortt in #328:
When two identical simulations are triggered nearly simultaneously (within milliseconds), the current ScenarioEndpoint implementation, which uses a LIFO stack, may associate the result of one simulation with the wrong request.

⚠️ Problem
Simulation 1 arrives

Simulation 2 arrives shortly after

Simulation 1 finishes and pushes its result

The stack pops the result, but it may be consumed by Simulation 2, violating the expected request-response association.

This leads to cross-contamination between simulations that should remain isolated.

✅ Solution
The stack has been replaced with a FIFO queue to ensure more predictable behavior. While this doesn't eliminate the theoretical risk of race conditions, the likelihood of misassignment is significantly reduced:

With a queue:

Simulation 1 finishes → result goes to Simulation 1

Simulation 2 finishes → result goes to Simulation 2

Only if Simulation 2 finishes before Simulation 1, and the queue is misused, could a mismatch still occur — but this is far less likely, especially with identical simulations where timing remains synchronized.

🔧 Additional Changes
Upgraded Citrus Core dependency to v4.6.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions