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

RuntimeException with null cause thrown by JMX method causes NPE in JminiX #26

Open
ipalopezhentsev opened this issue Nov 10, 2022 · 0 comments

Comments

@ipalopezhentsev
Copy link

ipalopezhentsev commented Nov 10, 2022

model.put(VALUE_MODEL_ATTRIBUTE, e.getTargetException().getCause().getMessage());

Scenario:

  • a user JMX attribute getter throws RuntimeException with null getCause() (for whatever reason; it is permitted by the exception contract).
  • it is picked up by the cited catch inside JMiniX. It is correctly logged by this line: log.warn("Error accessing attribute", e);
  • But the next line (referenced above) incorrectly assumes getCause() is always not null and causes NPE on calling getMessage().
  • So the user sees not the original error in browser, but overwritten stack trace, this time with NPE, logged by org.restlet.resource.ServerResource#doCatch (getLogger().log(level, "Exception or error caught in server resource", throwable);)

It makes it hard to debug jmx method failures in browser (you see the irrelevant NPE in causedBy section), you have to go to the app logs to find the original causedBy exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant