Problem
The Java FlagEvaluator uses synchronized methods because the WASM runtime is single-threaded. While PR #64 added JMH concurrent benchmarks, there are no functional correctness tests that verify thread safety under concurrent access.
Concurrent access is a common real-world pattern — multiple threads evaluating flags simultaneously while another thread updates state.
Scope
Add JUnit tests that verify:
- Concurrent evaluation — Multiple threads evaluating different flags simultaneously; all get correct results
- Concurrent evaluate + updateState — One thread updating flag state while others are evaluating; no crashes or corrupted results
- State consistency — After
updateState, all subsequent evaluations (from any thread) see the new state
- No deadlocks — High-contention scenarios with many threads don't deadlock
Implementation Notes
- Use
ExecutorService with a thread pool (e.g., 8-16 threads)
- Use
CountDownLatch for coordinated start
- Run enough iterations (1000+) to surface race conditions
- Assert correctness of every evaluation result, not just absence of exceptions
Reference
Problem
The Java
FlagEvaluatorusessynchronizedmethods because the WASM runtime is single-threaded. While PR #64 added JMH concurrent benchmarks, there are no functional correctness tests that verify thread safety under concurrent access.Concurrent access is a common real-world pattern — multiple threads evaluating flags simultaneously while another thread updates state.
Scope
Add JUnit tests that verify:
updateState, all subsequent evaluations (from any thread) see the new stateImplementation Notes
ExecutorServicewith a thread pool (e.g., 8-16 threads)CountDownLatchfor coordinated startReference
FlagEvaluatorsynchronization:java/src/main/java/dev/openfeature/flagd/evaluator/FlagEvaluator.javajava/src/main/java/dev/openfeature/flagd/evaluator/FlagEvaluatorBenchmark.java