Summary
MontonioClient.orders() uses lazy initialization without synchronization. Under concurrent access, multiple OrderService instances may be created (benign race — last write wins, no corruption). As more domain services are added, this pattern will repeat.
Context
Design decision from #16: opted for simplicity over thread safety since SDK clients are typically single-threaded. This issue tracks adding thread safety if it becomes a requirement.
Options
synchronized on orders() — simplest, minimal contention for a rarely-called method
volatile + double-checked locking — avoids synchronization on the hot path
- Eager initialization in constructor — simplest but allocates unused services
Acceptance Criteria
MontonioClient.orders() is safe to call concurrently from multiple threads
- No performance regression for single-threaded usage
Summary
MontonioClient.orders()uses lazy initialization without synchronization. Under concurrent access, multipleOrderServiceinstances may be created (benign race — last write wins, no corruption). As more domain services are added, this pattern will repeat.Context
Design decision from #16: opted for simplicity over thread safety since SDK clients are typically single-threaded. This issue tracks adding thread safety if it becomes a requirement.
Options
synchronizedonorders()— simplest, minimal contention for a rarely-called methodvolatile+ double-checked locking — avoids synchronization on the hot pathAcceptance Criteria
MontonioClient.orders()is safe to call concurrently from multiple threads