From c9a33c936b683403077846e8d98686cf2dbb43d5 Mon Sep 17 00:00:00 2001 From: Michael van Acken Date: Tue, 3 Jan 2012 11:42:44 -0800 Subject: [PATCH] have clojure-ns accept class names without $ When using aleph in combination with ring's wrap-stacktrace, certain exceptions are silently swallowed by the server. I traced this down to clojure-ns raising a null pointer exception for the class-name "lamina.core.observable.ConstantObservable", which is a defrecord. This changes clojure-ns to return "lamina.core.observable" as the ns. clojure-fn is unchanged and returns the full string, which is probably wrong. have clojure-ns accept class names without $ When using aleph in combination with ring's wrap-stacktrace, certain exceptions are silently swallowed by the server. I traced this down to clojure-ns raising a null pointer exception for the class-name "lamina.core.observable.ConstantObservable", which is a defrecord. This changes clojure-ns to return "lamina.core.observable" as the ns. clojure-fn is unchanged and returns the full string, which is probably wrong. --- src/clj_stacktrace/core.clj | 3 ++- test/clj_stacktrace/core_test.clj | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/clj_stacktrace/core.clj b/src/clj_stacktrace/core.clj index b7f428b..0d5c47e 100644 --- a/src/clj_stacktrace/core.clj +++ b/src/clj_stacktrace/core.clj @@ -11,7 +11,8 @@ (defn- clojure-ns "Returns the clojure namespace name implied by the bytecode class name." [class-name] - (utils/re-gsub #"_" "-" (utils/re-get #"([^$]+)\$" class-name 1))) + (utils/re-gsub #"_" "-" (or (utils/re-get #"([^$]+)\$" class-name 1) + (utils/re-get #"(.+)\.[^.]+$" class-name 1)))) ;; drop everything before and including the first $ ;; drop everything after and including and the second $ diff --git a/test/clj_stacktrace/core_test.clj b/test/clj_stacktrace/core_test.clj index 6c42843..b93a31a 100644 --- a/test/clj_stacktrace/core_test.clj +++ b/test/clj_stacktrace/core_test.clj @@ -40,6 +40,11 @@ {:clojure true :ns "user" :fn "eval" :file nil :line nil :anon-fn false}] + ["lamina.core.observable.ConstantObservable" "message" "observable.clj" 198 + {:clojure true :ns "lamina.core.observable" + :fn "lamina.core.observable.ConstantObservable" + :file "observable.clj" :line 198 :anon-fn false}] + ["clojure.lang.Var" "invoke" "Var.java" 123 {:java true :class "clojure.lang.Var" :method "invoke" :file "Var.java" :line 123}]