Completed
Details
Assignee
Alex MillerAlex MillerReporter
Rich HickeyRich HickeyLabels
Approval
OkPatch
CodePriority
MajorAffects versions
Fix versions
Details
Details
Assignee
Alex Miller
Alex MillerReporter
Rich Hickey
Rich HickeyLabels
Approval
Ok
Patch
Code
Priority

Affects versions
Fix versions
Created August 8, 2014 at 5:39 PM
Updated August 29, 2014 at 4:50 PM
Resolved August 29, 2014 at 4:50 PM
Transients protect themselves from use by any thread other than the one that creates them. This is good for safety, however it eliminates certain valid usages of transients. For example, usage in a go-block might occur in subsequent invocations across multiple OS threads (but only one logical thread of control).
Current simple test:
user> (def v (transient [])) #'user/v user> (persistent! @(future (conj! v 1))) IllegalAccessError Transient used by non-owner thread clojure.lang.PersistentVector$TransientVector.ensureEditable (PersistentVector.java:464)
Proposal: Remove the owner check from transient collections. (Leave the edit after persistent check as is.) The test above should succeed.
After:
user=> (def v (transient [])) #'user/v user=> (persistent! @(future (conj! v 1))) [1]
The clj-1498-3.diff version of the patch also replaces the AtomicReference<Thread> with AtomicBoolean as we can now track just ownership, not who owns it.
Doc update: Various pieces of documentation will need to be updated with this change, namely http://clojure.org/transients
Patch: clj-1498-3.diff
Alternative: Another idea would be to make this check optional with some kind of option on the transient call
(transient coll :check-owner true)
. Not sure whether what the default would be for that.