[
https://issues.apache.org/jira/browse/CURATOR-540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16930254#comment-16930254
]
HonglunChen commented on CURATOR-540:
-------------------------------------
[~cammckenzie]
Yes, it works that I add my listener after start() has returned. But I don't
think it is normal, whether or not to send an event depends on whether or not
PathChildrenCache.cacheData has the path. Since StartMode.BUILD_INITIAL_CACHE
has created the cacheData, in theory the history events will not be sent. But
now the problem is that when start, the CONNECTED state changes, and then the
history events will be sent. This can be confusing, and the
StartMode.BUILD_INITIAL_CACHE in version 2.7.1 is normal.
{code:java}
private void handleStateChange(ConnectionState newState)
{
switch ( newState )
{
case SUSPENDED:
{
offerOperation(new EventOperation(this, new
PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CONNECTION_SUSPENDED,
null)));
break;
}
case LOST:
{
offerOperation(new EventOperation(this, new
PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CONNECTION_LOST, null)));
break;
}
case CONNECTED:
case RECONNECTED:
{
try
{
offerOperation(new RefreshOperation(this,
RefreshMode.FORCE_GET_DATA_AND_STAT));
offerOperation(new EventOperation(this, new
PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED,
null)));
}
catch ( Exception e )
{
ThreadUtils.checkInterrupted(e);
handleException(e);
}
break;
}
}
}
{code}
> BUILD_INITIAL_CACHE mode will post history child on start
> ---------------------------------------------------------
>
> Key: CURATOR-540
> URL: https://issues.apache.org/jira/browse/CURATOR-540
> Project: Apache Curator
> Issue Type: Bug
> Components: Recipes
> Affects Versions: 2.12.0, 2.13.0
> Reporter: HonglunChen
> Priority: Major
> Attachments: image-2019-09-16-12-43-01-588.png
>
>
> I debugged and found the root cause : In PathChildrenCache, CONNECTED state
> is triggered before currentData initializes.
--
This message was sent by Atlassian Jira
(v8.3.2#803003)