[
https://issues.apache.org/jira/browse/CURATOR-391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15906691#comment-15906691
]
ASF GitHub Bot commented on CURATOR-391:
----------------------------------------
Github user dragonsinth commented on a diff in the pull request:
https://github.com/apache/curator/pull/202#discussion_r105569075
--- Diff:
curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
---
@@ -694,14 +695,23 @@ private void applyNewData(String fullPath, int
resultCode, Stat stat, byte[] byt
{
offerOperation(new EventOperation(this, new
PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CHILD_ADDED, data)));
}
- else if ( previousData.getStat().getVersion() !=
stat.getVersion() )
+ else if ( hasChanged(stat, previousData, data) )
{
offerOperation(new EventOperation(this, new
PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CHILD_UPDATED, data)));
}
updateInitialSet(ZKPaths.getNodeFromPath(fullPath), data);
}
}
+ private boolean hasChanged(Stat stat, ChildData previousData,
ChildData newData)
+ {
+ if ( cacheData )
+ {
+ return !Arrays.equals(previousData.getData(),
newData.getData());
--- End diff --
Yeah, that should actually be deterministic.
> PathChildrenCache missing events upon reconnection
> --------------------------------------------------
>
> Key: CURATOR-391
> URL: https://issues.apache.org/jira/browse/CURATOR-391
> Project: Apache Curator
> Issue Type: Bug
> Components: Recipes
> Reporter: Benjamin Jaton
> Assignee: Jordan Zimmerman
> Fix For: 3.3.1, 2.12.1
>
>
> PathChildrenCache attempts to check for any change that occurred during a
> connection loss in applyNewData():
> {code:title=PathChildrenCache.java|borderStyle=solid}
> else if ( previousData.getStat().getVersion() != stat.getVersion() )
> {code}
> The way to compare stats is erroneous. {{version}} will be reset if the node
> is recreated. So the above code only works if an update has been made, but it
> may miss changes that involve a delete event.
> Example:
> - node /tmp is just created, version=0
> - connection loss
> - node /tmp is deleted
> - node /tmp is recreated with new data, version=0
> - reconnect
> - no data change event from PathChildrenCache
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)