You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by prestona <gi...@git.apache.org> on 2015/05/25 22:39:48 UTC

[GitHub] qpid-proton pull request: PROTON-881: Graceful handling of runtime...

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 <pr...@uk.ibm.com>
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] qpid-proton pull request: PROTON-881: Graceful handling of runtime...

Posted by rhs <gi...@git.apache.org>.
Github user rhs commented on the pull request:

    https://github.com/apache/qpid-proton/pull/34#issuecomment-108444308
  
    Hi Preston, sorry to take so long to look at this.
    
    My impulse here would be to avoid using a checked exception for HandlerException. I generally follow the advice that you should only use checked exceptions for error conditions that a programmer can anticipate and recover from, and I'm not sure that's the case here. It's nice to have the HandlerException for debugging and clarity so it's obvious when the handler is at fault rather than the reactor implementation itself, but I'm not sure how someone could catch and recover if it is thrown. Making it unchecked would also allow you to avoid the EventImpl changes you mention in your comment.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] qpid-proton pull request: PROTON-881: Graceful handling of runtime...

Posted by prestona <gi...@git.apache.org>.
Github user prestona closed the pull request at:

    https://github.com/apache/qpid-proton/pull/34


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] qpid-proton pull request: PROTON-881: Graceful handling of runtime...

Posted by prestona <gi...@git.apache.org>.
Github user prestona commented on the pull request:

    https://github.com/apache/qpid-proton/pull/34#issuecomment-108472809
  
    No problem.  I'll re-work and submit another PR based around HandlerException being unchecked.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---