Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CLJ-983 - always update-proxy in proxy-super, regardless of whether c…

…all throws

Signed-off-by: Stuart Halloway <stu@cognitect.com>
  • Loading branch information...
commit 98206ab4443b331a537da6564524030a3e4887c1 1 parent d7175e8
@puredanger puredanger authored Stuart Halloway committed
View
6 src/clj/clojure/core_proxy.clj
@@ -358,9 +358,9 @@
(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)))
+ (try
+ (call)
+ (finally (update-proxy this m)))))
(defmacro proxy-super
"Use to call a superclass method in the body of a proxy method.
View
13 test/clojure/test_clojure/java_interop.clj
@@ -173,6 +173,19 @@
#{java.lang.Number java.lang.Object
java.lang.Comparable java.io.Serializable} ))
+(deftest test-proxy-super
+ (let [d (proxy [java.util.BitSet] []
+ (flip [bitIndex]
+ (try
+ (proxy-super flip bitIndex)
+ (catch IndexOutOfBoundsException e
+ (throw (IllegalArgumentException. "replaced"))))))]
+ ;; normal call
+ (is (nil? (.flip d 0)))
+ ;; exception should use proxied form and return IllegalArg
+ (is (thrown? IllegalArgumentException (.flip d -1)))
+ ;; same behavior on second call
+ (is (thrown? IllegalArgumentException (.flip d -1)))))
; Arrays: [alength] aget aset [make-array to-array into-array to-array-2d aclone]
; [float-array, int-array, etc]
Please sign in to comment.
Something went wrong with that request. Please try again.