<< Back to previous view

[CLJ-983] proxy-super does not restore original binding if call throws exception Created: 05/May/12  Updated: 05/May/12

Status: Open
Project: Clojure
Component/s: None
Affects Version/s: Release 1.1, Release 1.2, Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Valentin Mahrwald Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: bug

Attachments: Text File proxy_super.patch    

 Description   

The code for proxy-call-with-super internally used by proxy-super does not handle exceptions from the call method:

(defn proxy-call-with-super [call this meth]
(let [m (proxy-mappings this)]
(update-proxy this (assoc m meth nil))
(let [ret (call)]
(update-proxy this m)
ret)))

As a result the following sequence behaves unexpectedly:
(def obj (proxy [java.lang.ClassLoader] []
(loadClass [cl] (println "enter")
(proxy-super loadClass cl))))
(.loadClass obj "nonexistent")
;; prints enter, then throws ClassNotFoundException
(.loadClass obj "nonexistent")
;; does not print anything before throwing cnfe

A try-finally block around the invocation would solve this particular issue.



 Comments   
Comment by Valentin Mahrwald [ 05/May/12 9:04 AM ]

Test & fix patch on latest Clojure github branch.

Generated at Wed May 22 23:20:46 CDT 2013 using JIRA 4.4#649-r158309.