I'm not sure this is actually necessary. `java.lang.NullPointerException` extends `java.lang.RuntimeException` which in turn extends `java.lang.Exception` which is already being caught for this `try` block and returning 0.
IMO, it's less clean because now there are 2 places which are returning 0 in case of an error. In any case, it's really not a big deal.
One additional question here...Is this NPE mainly theoretical or is there a specific use-case which triggers it? If the former then I'm even less in favor of merging the PR. If the latter then it would be worth adding a test or maybe just describing the use-case in the commit message.
The NPEs occur that's why I opened this PR. Since they are only logged in debug level I only saw them while debugging some stomp issue I had.
Throwing an exception is a relatively expensive operation in the JVM because of the stacktrace information that needs to be generated, so in cases where it is know that a null value could be returned it one should not rely on an NPE to be catched.