[CLJ-1077] thread-bound? returns true (implying set! should succeed) even for non-binding thread Created: 26/Sep/12 Updated: 01/Feb/16
thread-bound? returns true for thread-local bindings that were not bound by the current thread. This is at odds with the docstring, which states that if true is returned, set! should succeed.
ere is an example REPL session where a thread establishes a binding, those bindings are conveyed to a second thread, the second thread checks thread-bound? to see if it can set the binding, thread-bound? returns true indicating that the binding can be set, the second thread tries to set the binding, and the second thread gets an IllegalStateException:
Approach: thread-bound? should return false in the case where there is a binding and that binding was not established by the current thread. The patch adds a new function to Var as core does not have visibility into the non-public Var$TBox.
Screened by: Alex Miller
|Comment by Paul Stadig [ 01/Oct/12 10:07 AM ]|
I have attached a patch that changes clojure.lang.Var and clojure.core/thread-bound? to only return true if a Var is set!-able.
|Comment by Alex Miller [ 19/Aug/13 12:16 PM ]|
|Comment by Joe Gallo [ 20/Aug/13 7:55 AM ]|
Sure thing, Alex – here's a repl example I just ran this morning.