dropwizard/metrics

Certain metric names cause MalformedObjectNameException in JMX clients

amrith92 opened this issue · 1 comments

The default managed object naming strategy used by JMX reporter does not handle metric names with quotable characters appropriately, causing various JMX clients like jmxtrans to fail RMI object deserialization with MalformedObjectNameException. Here's a reproducer code snippet:

DefaultObjectNameFactory f = new DefaultObjectNameFactory();
ObjectName on = f.createName("type", "com.domain", "something.with.quotes(\"ABcd\")");
assertThatCode(() -> new ObjectName(on.toString())).doesNotThrowAnyException();

The object on is created without raising exceptions, however parsing its serialized form (which is what happens in clients like jmxtrans) causes MalformedObjectNameException to be thrown.

It is not clear to me whether the JDK should be checking for validly quoted values for object name properties, or whether the onus is on clients of the javax.management APIs to appropriately shape the values.

Any metric name containing the following characters result in this behaviour: " , = :

@amrith92 Thanks for reporting this and providing a fix. ❤️