[CLJ-1104] Concurrent with-redefs do not unwind properly, leaving a var permanently changed Created: 07/Nov/12 Updated: 21/Dec/12
|Affects Version/s:||Release 1.4, Release 1.5|
|Fix Version/s:||Approved Backlog|
Mac OS, Java 6
On 1.4 and latest master:
user> (defn ten  10)
Not sure if this is a bug per se, but the doc doesn't mention lack of concurrency safety and my expectation was that the original value would always be restored after any (arbitrarily interleaved) sequence of with-redefs calls.
|Comment by Tim McCormack [ 07/Nov/12 8:50 PM ]|
The with-redefs doc (v1.4.0) says "These temporary changes will be visible in all threads." That sounds non-thread-safe to me.
In general, changes to var root bindings are not thread safe.
|Comment by Herwig Hochleitner [ 08/Nov/12 9:17 AM ]|
As I understand it, with-redefs is mainly used in test suites to mock out vars. It was introduced when vars became static by default and a lot of testsuites had been using binding for mocking. Maybe the docstring should be amended with something along the lines of: When using this you have to ensure that only a single thread is interacting with redef'd vars.
|Comment by Stuart Halloway [ 25/Nov/12 6:41 PM ]|
Behavior find as is, doc string change would be fine.
|Comment by Andy Fingerhut [ 25/Nov/12 6:57 PM ]|
Patch clj-1104-doc-unsafety-of-concurrent-with-redefs-v1.txt dated Nov 25 2012 updates doc string of with-redefs to make it clear that concurrent use is unsafe.