You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by madrob <gi...@git.apache.org> on 2015/05/12 19:21:45 UTC

[GitHub] curator pull request: CURATOR-219 Catch Exceptions, not Throwables

GitHub user madrob opened a pull request:

    https://github.com/apache/curator/pull/78

    CURATOR-219 Catch Exceptions, not Throwables

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/madrob/curator CURATOR-219

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/curator/pull/78.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 #78
    
----
commit 865b4a6bbac6e486f85bc725cb15a69efdfd0521
Author: Mike Drob <md...@cloudera.com>
Date:   2015-05-12T17:18:19Z

    CURATOR-219 Catch Exceptions, not Throwables

----


---
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] curator pull request: CURATOR-219 Catch Exceptions, not Throwables

Posted by Randgalt <gi...@git.apache.org>.
Github user Randgalt commented on a diff in the pull request:

    https://github.com/apache/curator/pull/78#discussion_r32884938
  
    --- Diff: curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java ---
    @@ -301,7 +301,7 @@ else if ( port != thePort )
                         values.putAll(decodeExhibitorList(encoded));
                         done = true;
                     }
    -                catch ( Throwable e )
    +                catch ( Exception e )
    --- End diff --
    
    I don't understand how this is an improvement. Exceptions such as NPE or OOM would be lost with this change. By catching Throwable, those exceptions are logged.


---
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] curator pull request: CURATOR-219 Catch Exceptions, not Throwables

Posted by SamG1000 <gi...@git.apache.org>.
Github user SamG1000 commented on a diff in the pull request:

    https://github.com/apache/curator/pull/78#discussion_r58293712
  
    --- Diff: curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java ---
    @@ -301,7 +301,7 @@ else if ( port != thePort )
                         values.putAll(decodeExhibitorList(encoded));
                         done = true;
                     }
    -                catch ( Throwable e )
    +                catch ( Exception e )
    --- End diff --
    
    You also need to \worry about ThreadDeath error:
    
    https://docs.oracle.com/javase/7/docs/api/java/lang/ThreadDeath.html
    ```
    An application should catch instances of this class only if it must clean up after being terminated asynchronously. If ThreadDeath is caught by a method, it is important that it be rethrown so that the thread actually dies.
    ```
    
    So ThreadDeath Error can be logged, but should never retry to avoid destabilizing JVM.


---
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] curator pull request: CURATOR-219 Catch Exceptions, not Throwables

Posted by madrob <gi...@git.apache.org>.
Github user madrob commented on a diff in the pull request:

    https://github.com/apache/curator/pull/78#discussion_r32885316
  
    --- Diff: curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java ---
    @@ -301,7 +301,7 @@ else if ( port != thePort )
                         values.putAll(decodeExhibitorList(encoded));
                         done = true;
                     }
    -                catch ( Throwable e )
    +                catch ( Exception e )
    --- End diff --
    
    NPE still gets caught. If OOM is thrown, does it really make sense to retry? That's usually a pretty drastic condition and very often the JVM is not actually in a recoverable state. The OOM can be thrown because of a different thread going wonky, and we have no way to clean up the resources it was using.


---
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] curator pull request: CURATOR-219 Catch Exceptions, not Throwables

Posted by Randgalt <gi...@git.apache.org>.
Github user Randgalt commented on a diff in the pull request:

    https://github.com/apache/curator/pull/78#discussion_r32886052
  
    --- Diff: curator-client/src/main/java/org/apache/curator/ensemble/exhibitor/ExhibitorEnsembleProvider.java ---
    @@ -301,7 +301,7 @@ else if ( port != thePort )
                         values.putAll(decodeExhibitorList(encoded));
                         done = true;
                     }
    -                catch ( Throwable e )
    +                catch ( Exception e )
    --- End diff --
    
    Probably not. But, I'd view that as a separate issue. It's technically up to the retry policy passed to ExhibitorEnsembleProvider.


---
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] curator pull request: CURATOR-219 Catch Exceptions, not Throwables

Posted by Randgalt <gi...@git.apache.org>.
Github user Randgalt commented on a diff in the pull request:

    https://github.com/apache/curator/pull/78#discussion_r32884956
  
    --- Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java ---
    @@ -812,31 +812,28 @@ private void performBackgroundOperation(OperationAndData<?> operationAndData)
                     queueOperation(operationAndData);
                 }
             }
    -        catch ( Throwable e )
    +        catch ( CuratorConnectionLossException e )
    --- End diff --
    
    Similar to above. If Throwable is not caught, the exception will be lost. By catching Throwable, the exception will get logged.


---
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.
---