Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certain metric names cause MalformedObjectNameException in JMX clients #2030

Closed
amrith92 opened this issue Jun 16, 2021 · 1 comment · Fixed by #2031
Closed

Certain metric names cause MalformedObjectNameException in JMX clients #2030

amrith92 opened this issue Jun 16, 2021 · 1 comment · Fixed by #2031
Labels
Milestone

Comments

@amrith92
Copy link
Contributor

amrith92 commented Jun 16, 2021

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 added a commit to amrith92/metrics that referenced this issue Jun 16, 2021
…erties with values that are unquoted if the aforementioned values contain any of comma, equals, colon or double-quote characters. This fixes the default object naming strategy used by JMX reporter.
@joschi joschi added this to the 4.1.23 milestone Jun 16, 2021
@joschi joschi added the bug label Jun 16, 2021
joschi pushed a commit that referenced this issue Jun 16, 2021
JMX managed ObjectNames cannot contain properties with values that are unquoted if the aforementioned values contain any of comma, equals, colon or double-quote characters. This fixes the default object naming strategy used by JMX reporter.

Note that construction of the `ObjectName` does not fail, but JMX clients break on deserialization.

Fixes #2030
@joschi
Copy link
Member

joschi commented Jun 16, 2021

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

joschi pushed a commit that referenced this issue Jun 16, 2021
JMX managed ObjectNames cannot contain properties with values that are unquoted if the aforementioned values contain any of comma, equals, colon or double-quote characters. This fixes the default object naming strategy used by JMX reporter.

Note that construction of the `ObjectName` does not fail, but JMX clients break on deserialization.

Fixes #2030

(cherry picked from commit 3ac20d3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants