GitHub user prestona opened a pull request:
https://github.com/apache/qpid-proton/pull/34
PROTON-881: Graceful handling of runtime exceptions thrown within hanâ¦
Adds support for more gracefully handling runtime exceptions thrown from
within a handler.
When a runtime (unchecked) exceptions is thrown within a handler, the
reactor now catches it and throws a HandlerException (which is a checked
exception). The HandlerException references the Handler that threw the
original exception and also chains the original exception as its "cause".
One facet of this PR that I'm not 100% happy with is the changes to
EventImpl. Really EventImpl.dispatch() should throw HandlerException - but
this would be a pretty disruptive change, so instead I've added a 'lastHandler'
attribute to the class which remembers the last handler to be dispatched. This
means that if a handler throws an exception inside the dispatch() method the
calling class can discover which handler was responsible (even if dispatch()
has recursed into one, or more, level of child handler).
If there's a better way to do this (I'm sure it'll be really obvious in
hindsight...), please let me know and I'll resubmit the PR with the changes.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/prestona/qpid-proton reactor
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/qpid-proton/pull/34.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #34
----
commit 709c76f48008e5e593b723d6d59bbbc89b0d5e97
Author: Adrian Preston <[email protected]>
Date: 2015-05-25T20:22:48Z
PROTON-881: Graceful handling of runtime exceptions thrown within handlers
When a runtime (unchecked) exceptions is thrown within a handler, the
reactor
now catches it and throws a HandlerException (which is a checked exception).
The HandlerException references the Handler that threw the original
exception
and also chains the original exception as its "cause".
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---