Clojure

proxy-super does not restore original binding if call throws exception

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.1, Release 1.2, Release 1.3
  • Fix Version/s: None
  • Component/s: None
  • Labels:

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.

Activity

Hide
Valentin Mahrwald added a comment -

Test & fix patch on latest Clojure github branch.

Show
Valentin Mahrwald added a comment - Test & fix patch on latest Clojure github branch.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: