<< Back to previous view

[CLJ-961] with-redefs loses a Var's root binding if the Var is thread-bound Created: 28/Mar/12  Updated: 20/Jul/12  Resolved: 20/Jul/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Jiří Maršík Assignee: Rich Hickey
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-with-redefs-saves-root-binding-instead-of-thread-loc.patch     File with_redefs_bug.clj    
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.



 Comments   
Comment by Aaron Bedra [ 10/Jul/12 6:53 PM ]

I paired with Gary on this and tested the patch on my machine after it was uploaded.

Generated at Fri Nov 28 05:20:31 CST 2014 using JIRA 4.4#649-r158309.