Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@ipalopezhentsev

Description

@ipalopezhentsev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions