Jeff Mesnil

jmx4r 0.1.2 Is Released

jmx4r 0.1.2 has just been released (jmx4r is a JRuby library which makes it super easy to write simple Ruby scripts to manage Java & JRuby applications using JMX).

  • it fixes a bug in the getAttributes() method that is exposed by Ruby objects extending jmx4r’s DynamicMBean class

I introduced the bug but it is one of the rare cases where I would still blame JMX API. Its DynamicMBean interface has two methods:

  • getAttribute(String attribute)
  • getAttributes(String[] attributes)

Following the principle of least surprise, I expected getAttribute(String) to return the value of the attribute and getAttributes(String[]) to return a collection of the attribute values. But that’s not the case. As expected getAttribute(String) returns the value of the attribute but getAttributes(String[]) returns a AttributeList which is a list of Attribute objects (which in turns contains the name and value of an attribute).
jmx4R 0.1.2 fixes the issue and make sure the methods return the correct objects.

JMX is one of my favorite Java API, simple, flexible and powerful at the same time. Its evolution made it both a bit uglier and more convenient (I wish open types were more simpler to use and less verbose to declare). Providing a library to use JMX in JRuby applications is the perfect match between a simple and powerful library (JMX) and a simple and powerful language (Ruby) on a simple and powerful platform (JVM).

From time to time, I receive mails inquiring about the status of jmx4r.
I no longer use jmx4r in my daily job and it is not actively developed. However it is actively maintained. If you find bugs, I can release a new version quite fast. jmx4r users are awesome and most of the time, they provide patches when they report bugs.
If you have ideas for improvements, do not hesitate to send me a mail or fork the project. Most recent contributions were done through forks on GitHub.

Once again, thanks to all the contributors and users who help make jmx4r even more useful!

As usual, to get this new release, just update the rubygem:

jruby -S gem install jmx4r

and do not hesitate to contribute:

git clone git://github.com/jmesnil/jmx4r.git

Comments

  • Hi Jeff!

    I wasn’t around for the design of the DynamicMBean interface but the fact that getAttributes returns an AttributeList rather than an Object[] has some justification. The point is that if getting some of the attributes produces an exception, the returned AttributeList contains just those attributes that did not. (Then you can get the missing attributes one by one to see what the exceptions were.)

    In the case of getAttributes a good case could be made that it should just throw the first exception it encounters, but for setAttributes that’s less obvious. If an exception is thrown then which attributes have been changed, if any? A clean solution would be to say that setAttributes must be atomic, i.e. all values must be set or none of them, but that’s more work for MBean writers and in particular would be tricky for Standard MBeans.

    Éamonn McManus, JMX Spec Lead

  • Comments closed