Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for dependency memoization race condition (#40)
The Class monkey patch that adds the dependency method creates a getter method with the same name as the dependency specified. This method uses a simple check-and-set approach to cache the dependency: * get the value of an instance variable that caches the dependency instance; * if non-nil, return that value; * if nil, get the dependency, assign it to the instance variable, then return it. This is intended to ensure that the getter method always returns the same instance of the dependency. However, this check-and-set is not thread-safe and can result in different instances being returned before the instance variable is set. This adds a pending test for this bug so that we can know when the bug has been fixed. Co-authored-by: Tim Regener <[email protected]>
- Loading branch information