Permalink
Browse files

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.
  • Loading branch information...
1 parent d5a8969 commit c9a33c936b683403077846e8d98686cf2dbb43d5 @mva mva committed with technomancy Jan 3, 2012
Showing with 7 additions and 1 deletion.
  1. +2 −1 src/clj_stacktrace/core.clj
  2. +5 −0 test/clj_stacktrace/core_test.clj
View
3 src/clj_stacktrace/core.clj
@@ -11,7 +11,8 @@
(defn- clojure-ns (defn- clojure-ns
"Returns the clojure namespace name implied by the bytecode class name." "Returns the clojure namespace name implied by the bytecode class name."
[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 before and including the first $
;; drop everything after and including and the second $ ;; drop everything after and including and the second $
View
5 test/clj_stacktrace/core_test.clj
@@ -40,6 +40,11 @@
{:clojure true :ns "user" :fn "eval" {:clojure true :ns "user" :fn "eval"
:file nil :line nil :anon-fn false}] :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 ["clojure.lang.Var" "invoke" "Var.java" 123
{:java true :class "clojure.lang.Var" :method "invoke" {:java true :class "clojure.lang.Var" :method "invoke"
:file "Var.java" :line 123}] :file "Var.java" :line 123}]

0 comments on commit c9a33c9

Please sign in to comment.