<< Back to previous view

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

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

Type: Defect Priority: Major
Reporter: Valentin Mahrwald Assignee: Unassigned
Resolution: Completed Votes: 4
Labels: interop

Attachments: Text File clj-983-2.patch     Text File proxy_super.patch    
Patch: Code and Test
Approval: Ok

 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

Patch: clj-983-2.patch

Approach: Use a try-finally block around the invocation to perform the after invocation action regardless of exceptions.

Screened by: Stuart Sierra



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

Test & fix patch on latest Clojure github branch.

Comment by Alex Miller [ 26/Dec/13 7:24 AM ]

Patch provider does not have a signed CA so can't be accepted as is.

Comment by Alex Miller [ 03/Jan/14 12:33 PM ]

Marked vetted in 1.6 per Rich.

Comment by Alex Miller [ 06/Jan/14 1:07 PM ]

Incomplete - needs clean patch.

Comment by Alex Miller [ 06/Jan/14 3:06 PM ]

Added new clean patch for screening consideration.

Comment by Stuart Sierra [ 10/Jan/14 4:22 PM ]

Screened OK.

Generated at Thu Jul 31 02:32:43 CDT 2014 using JIRA 4.4#649-r158309.