Permalink
Browse files

Support null values returned for mbean attributes.

patch by Jürgen Hötzel for JMX-7
  • Loading branch information...
1 parent e526bc7 commit 31b58b9c78baa9f6f31a51cd6e8b8b729af4622a @nickmbailey nickmbailey committed Sep 19, 2012
Showing with 11 additions and 10 deletions.
  1. +3 −1 src/main/clojure/clojure/java/jmx.clj
  2. +8 −9 src/test/clojure/clojure/java/test_jmx.clj
@@ -146,7 +146,9 @@
(into {} (zipmap (keys m) (map objects->data (vals m)))))
Object
- (objects->data [obj] obj))
+ (objects->data [obj] obj)
+ nil
+ (objects->data [_] nil))
(def ^{:private true} guess-attribute-map
{"java.lang.Integer" "int"
@@ -106,14 +106,6 @@
(jmx/invoke-signature "java.lang:type=Threading" :getThreadInfo ["long" "int"] 1 (new java.lang.Integer 1))))
(deftest test-objects->data
- (testing "it works recursively on maps"
- (let [some-map {:foo (jmx/raw-read "java.lang:type=Memory" :HeapMemoryUsage)}]
- (is (map? (:foo (jmx/objects->data some-map))))))
- (testing "it leaves everything else untouched"
- (is (= "foo" (jmx/objects->data "foo")))))
-
-
-(deftest test-objects->data
(let [objects (jmx/raw-read "java.lang:type=Memory" :HeapMemoryUsage)
prox (jmx/objects->data objects)]
(testing "returns a map with keyword keys"
@@ -122,7 +114,14 @@
props (jmx/objects->data raw-props)]
(are [k] (contains? props k)
:java.class.path
- :path.separator)))
+ :path.separator))
+ (testing "it works recursively on maps"
+ (let [some-map {:foo (jmx/raw-read "java.lang:type=Memory" :HeapMemoryUsage)}]
+ (is (map? (:foo (jmx/objects->data some-map))))))
+ (testing "it handles null references"
+ (is (nil? (jmx/objects->data nil))))
+ (testing "it leaves everything else untouched"
+ (is (= "foo" (jmx/objects->data "foo")))))
(deftest test-creating-attribute-infos
(let [infos (@#'jmx/map->attribute-infos [[:a 1] [:b 2]])

0 comments on commit 31b58b9

Please sign in to comment.