diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2010-03-30 12:57:51 -0400 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-03-30 12:57:51 -0400 |
commit | d157d6487e8c04979850b8d572cb0341613d97c1 (patch) | |
tree | 564d59f17e9a1077d9d0c92912982de808a1c90f | |
parent | a0178aeaf9493a19d68c0f4a998d865fa48e269d (diff) |
simplify jmx/read-supported and improve test output
-rw-r--r-- | src/main/clojure/clojure/contrib/jmx/client.clj | 23 | ||||
-rw-r--r-- | src/test/clojure/clojure/contrib/test_jmx.clj | 2 |
2 files changed, 5 insertions, 20 deletions
diff --git a/src/main/clojure/clojure/contrib/jmx/client.clj b/src/main/clojure/clojure/contrib/jmx/client.clj index 66eb336b..e8616296 100644 --- a/src/main/clojure/clojure/contrib/jmx/client.clj +++ b/src/main/clojure/clojure/contrib/jmx/client.clj @@ -40,31 +40,16 @@ (comp jmx->clj raw-read) "Read an mbean property.") -(defvar read-exceptions - [UnsupportedOperationException - InternalError - java.io.NotSerializableException - java.lang.ClassNotFoundException - javax.management.AttributeNotFoundException - javax.management.RuntimeMBeanException] - "Exceptions that might be thrown if you try to read an unsupported - attribute. Found these by testing agains jconsole and Tomcat. This - is dreadful and ad-hoc but I did not want to swallow all - exceptions.") - (defn read-supported "Calls read to read an mbean property, *returning* unsupported operation exceptions instead of throwing them. Used to keep mbean - from blowing up. Note that some terribly-behaved mbeans use - java.lang.InternalError to indicate an unsupported operation!" + from blowing up. Note: There is no good exception that aggregates + unsupported operations, hence the overly-general catch block." [n attr] (try (read n attr) - (catch Throwable t - (let [cause (root-cause t)] - (if (some #(instance? % cause) read-exceptions) - cause - (throw t)))))) + (catch Exception e + e))) (defn write! [n attr value] (.setAttribute diff --git a/src/test/clojure/clojure/contrib/test_jmx.clj b/src/test/clojure/clojure/contrib/test_jmx.clj index 24d6b975..83065fa9 100644 --- a/src/test/clojure/clojure/contrib/test_jmx.clj +++ b/src/test/clojure/clojure/contrib/test_jmx.clj @@ -113,7 +113,7 @@ (deftest various-beans-are-readable (testing "that all java.lang beans can be read without error" (doseq [mb (jmx/mbean-names "*:*")] - (jmx/mbean mb)))) + (is (map? (jmx/mbean mb)) mb)))) (deftest test-jmx-url (testing "creates default url" |