I had a look at the java.jmx code and worked out and tested s simple fix: diff --git a/src/main/clojure/clojure/java/jmx.clj b/src/main/clojure/ clojure/java/jmx.clj index 128e516..3d291a3 100644 --- a/src/main/clojure/clojure/java/jmx.clj +++ b/src/main/clojure/clojure/java/jmx.clj @@ -203,9 +203,16 @@ (into-array (map name attrs))))) (.getAttribute *connection* (as-object-name n) (name attrs))))
+(defn- array-chk + "Check if v is Java array and if so, convert it to vector" + [v] + (if (.isArray (class v)) + (vec v) + v)) + (def ^{:doc "Read one or more mbean properties."} read - (comp objects->data raw-read)) + (comp array-chk objects->data raw-read)) user=> (require '[clojure.java.jmx :as jmx]) nil user=> (jmx/read "java.lang:type=Threading" :AllThreadIds) [11 10 6 3 2 1] This also makes sure that values returned by read and mbean functions are immutable. On Feb 24, 3:32 am, Nick Bailey <nickmbai...@gmail.com> wrote: > I'm not sure that java.jmx should be attempting to do any conversion > of the values returned over jmx. I think it should be the > application's responsibility to convert types appropriately for how > they are needed. > > > > > > > > On Wed, Feb 22, 2012 at 7:47 PM, zoka <ztomi...@gmail.com> wrote: > > I was trying to convert result of JMX attributes query to JSON, and > > encountered problem while reading one particular attribute value of > > java.lang:type=Threading. Here is the REPL transcript: > > > demo.server=> (require '[clojure.java.jmx :as jmx]) > > nil > > demo.server=> (jmx/read "java.lang:type=Threading" :AllThreadIds) > > #<long[] [J@1bd97d0d> > > demo.server=> > > > This seems to be Java long array reference, > > > The jmx/mbean function that returns all attribute name as keywords > > associated with their values carries this value through. Attempt to > > convert such map to JSON string causes exception, since in this case > > a clojure vector of longs would be expected instead of Java array. > > > This particular piece information (list of application ThreadIs) is > > not of particular interest to me anyway, so it is easy just to remove > > the offending map entry as a workaround. > > > I have noticed some recent activity in clojure.java.jmx github repo, > > so I thought it would be appropriate to rise this issue, since it may > > be affecting some other attributes as well. > > > Regards > > Zoka > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en