Skip to content

Commit

Permalink
have clojure-ns accept class names without $
Browse files Browse the repository at this point in the history
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
mva authored and technomancy committed Jan 3, 2012
1 parent d5a8969 commit c9a33c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/clj_stacktrace/core.clj
Expand Up @@ -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 $
Expand Down
5 changes: 5 additions & 0 deletions test/clj_stacktrace/core_test.clj
Expand Up @@ -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}]
Expand Down

0 comments on commit c9a33c9

Please sign in to comment.