You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Collections passed to set() are shared across samples instead of copied (1.2.x regression) #1348
When a collection is passed to set(...), 1.2.x assigns that exact instance to the generated object instead of copying it. As a result, every sample() from the same builder returns an object that shares one collection instance, so mutating one sampled object mutates all of them.
It also means the collection type passed in leaks through. For example, Arrays.asList(...) produces a fixed-size list, so remove on the sampled object's list throws UnsupportedOperationException.
In 1.1.21 each sample received its own ArrayList copy. The 1.2.0 release notes say .set() is unchanged, so this looks unintended.
Your environment
Fixture Monkey 1.2.3 (fixture-monkey-starter). Works in 1.1.21.
Each sample() gets its own collection instance, as in 1.1.x, so samples are independent of each other and of the value passed to set.
Actual behaviour
first.items == second.items is true, and second.items contains [a, b, c].
In the second test, the sampled list is the java.util.Arrays$ArrayList that was passed in, and remove(0) throws java.lang.UnsupportedOperationException.
Activity