Seems for me these tow variables should be populated only, if `success` from the next statement. And `if...else` will be simplified. The `race condition` is protected by locked `localLock`.