jminix
jminix copied to clipboard
RuntimeException with null cause thrown by JMX method causes NPE in JminiX
https://github.com/lbovet/jminix/blob/6115206e43d0ba32388092dfca1bd0761817e10a/src/main/java/org/jminix/console/resource/AttributeResource.java#L150
Scenario:
- a user JMX attribute getter throws
RuntimeExceptionwith nullgetCause()(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 callinggetMessage(). - 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.