Clojure

with-redefs loses a Var's root binding if the Var is thread-bound

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Completed
  • Affects Version/s: Release 1.3
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

When a Var has an in-thread binding and I use with-redefs to temporarily alter its root binding, the value restored to the root binding after with-redefs is finished will not be the original root value, but the thread-local one. The problem is using deref instead of something like clojure.lang.Var's .getRawRoot to backup the original root values in with-derefs-fn.

I have never used with-redefs and it is very unlikely that one would use it while the Vars in question are thread-bound. However, when reading the function's definition in Joy of Clojure and later in core.clj, I did not believe this behaviour was intended.

Activity

Gary Fredericks made changes -
Field Original Value New Value
Assignee Gary Fredericks [ gfredericks ]
Gary Fredericks made changes -
Patch Code and Test [ 10002 ]
Approval Test [ 10013 ]
Attachment 0001-with-redefs-saves-root-binding-instead-of-thread-loc.patch [ 11375 ]
Aaron Bedra made changes -
Approval Test [ 10013 ] Screened [ 10004 ]
Aaron Bedra made changes -
Assignee Gary Fredericks [ gfredericks ] Rich Hickey [ richhickey ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: