Skip to content

Conversation

genuss
Copy link
Contributor

@genuss genuss commented Aug 1, 2025

According to javadoc getPlatformMXBean may throw IllegalArgumentException in case if mxbeanInterface is not a platform management interface or not a singleton platform MXBean. This is currently the case for graalvm native image (at least for 24.0.2).

I hesitated to add a test, but it looks a bit excessive. I also thought, maybe it's better to catch all j.l.Exceptions for simplicity?

IllegalArgumentException may be thrown by
ManagementFactory#getPlatformMXBean() in case if is not a
platform management interface or not a singleton platform MXBean.

Signed-off-by: Alexey Genus <genus.alexey@gmail.com>
@jonatan-ivanov jonatan-ivanov force-pushed the feature/skip-vtsmxbean branch from c177071 to bbc25dd Compare August 1, 2025 22:17
@jonatan-ivanov jonatan-ivanov changed the base branch from main to 1.15.x August 1, 2025 22:18
@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Aug 1, 2025

Thanks for the PR!
I think this should be qualified as a bug and since the JMX support for this was introduced in 1.15.x, I rebased your changes based on that branch so this will be fixed in 1.15 and above.

I also thought, maybe it's better to catch all j.l.Exceptions for simplicity?

Since the exception is swallowed I think it's fine to keep them narrower.

(Catching Exception and log it out might make sense though, but I think that could be in another PR on main as an enhancement.)

@jonatan-ivanov jonatan-ivanov added this to the 1.15.3 milestone Aug 1, 2025
@jonatan-ivanov jonatan-ivanov changed the title Catch IllegalArgumentException which may be thrown by ManagementFactory#getPlatformMXBean() Catch IllegalArgumentException in VirtualThreadMetrics Aug 1, 2025
@jonatan-ivanov jonatan-ivanov merged commit 970685e into micrometer-metrics:1.15.x Aug 1, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants