[ 
https://issues.apache.org/jira/browse/CURATOR-258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14877339#comment-14877339
 ] 

ASF GitHub Bot commented on CURATOR-258:
----------------------------------------

Github user Randgalt commented on a diff in the pull request:

    https://github.com/apache/curator/pull/102#discussion_r39924798
  
    --- Diff: 
curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
 ---
    @@ -74,10 +74,18 @@
             @Override
             public void process(WatchedEvent event)
             {
    -           if ( event.getType() == EventType.NodeDeleted)
    -           {
    -                   createNode();
    -           }
    +            if ( event.getType() == EventType.NodeDeleted)
    +            {
    +                createNode();
    +            }
    +            else if ( event.getType() == EventType.NodeDataChanged)
    +            {
    +                try {
    +                    watchNode();
    +                } catch (Exception e) {
    +                    log.error(String.format("Unexpected error during 
watching of path: %s", basePath), e);
    --- End diff --
    
    Maybe switch to a CuratorWatcher and let it handle the exception.


> PersistentEphemeralNode stops watching after first WatchedEvent
> ---------------------------------------------------------------
>
>                 Key: CURATOR-258
>                 URL: https://issues.apache.org/jira/browse/CURATOR-258
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 3.0.0, 2.8.0, 2.9.0, 2.9.1
>            Reporter: Njal Karevoll
>
> The `Watcher` in the `PersistentEphemeralNode` recipe only reacts to the 
> `NodeDeleted` event. But it's possible to receive a `NodeDataChanged` event 
> as well due to
>  1. The node has been created before the recipe has been started, so the 
> first event it receives is it's own update.
>  2. The node has been created by another session, and the recipe accepts 
> updating nodes belonging to a different session. In this case, it also 
> receives it's own update in the `Watcher`, and no longer watches the node 
> when the `NodeDeleted` event comes through (after the session of the other 
> client expires). This is easily reproducible by restarting a service using a 
> the recipe when the session timeout is higher than the service restart time. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to