Skip to content
Snippets Groups Projects
Commit 3201d22c authored by Ryan Senior's avatar Ryan Senior Committed by GitHub
Browse files

Merge pull request #5471 from metabase/aot-get-stack-trace-bug

Workaround for AOT protocol bug with getStackTrace
parents b7c6965e 090cc7b1
Branches
Tags
No related merge requests found
......@@ -575,16 +575,26 @@
(filtered-stacktrace [this]
"Get the stack trace associated with E and return it as a vector with non-metabase frames filtered out."))
;; These next two functions are a workaround for this bug https://dev.clojure.org/jira/browse/CLJ-1790
;; When Throwable/Thread are type-hinted, they return an array of type StackTraceElement, this causes
;; a VerifyError. Adding a layer of indirection here avoids the problem. Once we upgrade to Clojure 1.9
;; we should be able to remove this code.
(defn- throwable-get-stack-trace [^Throwable t]
(.getStackTrace t))
(defn- thread-get-stack-trace [^Thread t]
(.getStackTrace t))
(extend nil
IFilteredStacktrace {:filtered-stacktrace (constantly nil)})
(extend Throwable
IFilteredStacktrace {:filtered-stacktrace (fn [^Throwable this]
(filtered-stacktrace (.getStackTrace this)))})
IFilteredStacktrace {:filtered-stacktrace (fn [this]
(filtered-stacktrace (throwable-get-stack-trace this)))})
(extend Thread
IFilteredStacktrace {:filtered-stacktrace (fn [^Thread this]
(filtered-stacktrace (.getStackTrace this)))})
IFilteredStacktrace {:filtered-stacktrace (fn [this]
(filtered-stacktrace (thread-get-stack-trace this)))})
;; StackTraceElement[] is what the `.getStackTrace` method for Thread and Throwable returns
(extend (Class/forName "[Ljava.lang.StackTraceElement;")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment