[
https://issues.apache.org/jira/browse/CURATOR-332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15303045#comment-15303045
]
ASF GitHub Bot commented on CURATOR-332:
----------------------------------------
Github user dragonsinth commented on a diff in the pull request:
https://github.com/apache/curator/pull/154#discussion_r64829650
--- Diff:
curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java
---
@@ -121,22 +123,38 @@ public QuorumVerifier getCurrentConfig()
return currentConfig.get();
}
+ @VisibleForTesting
+ public boolean hasOutstanding()
+ {
+ return outstanding.get() > 0;
+ }
+
private void reset() throws Exception
{
- if ( client.getState() == CuratorFrameworkState.STARTED )
+ if ( (client.getState() == CuratorFrameworkState.STARTED) &&
(state.get() == State.STARTED) )
{
BackgroundCallback backgroundCallback = new
BackgroundCallback()
{
@Override
public void processResult(CuratorFramework client,
CuratorEvent event) throws Exception
{
+ outstanding.decrementAndGet();
if ( (event.getType() == CuratorEventType.GET_CONFIG)
&& (event.getResultCode() == KeeperException.Code.OK.intValue()) )
{
processConfigData(event.getData());
}
}
};
-
client.getConfig().usingWatcher(this).inBackground(backgroundCallback).forEnsemble();
+ outstanding.incrementAndGet();
+ try
+ {
+
client.getConfig().usingWatcher(this).inBackground(backgroundCallback).forEnsemble();
+ }
+ catch ( Exception e )
+ {
+ outstanding.decrementAndGet();
+ throw e;
+ }
--- End diff --
you could also formulate this as:
```
outstanding.incrementAndGet();
try
{
client.getConfig().usingWatcher(this).inBackground(backgroundCallback).forEnsemble();
outstanding.incrementAndGet();
}
finally
{
outstanding.decrementAndGet();
}
```
> Internal watcher tracking for new WatcherRemoveCuratorFramework feature is
> not correct
> --------------------------------------------------------------------------------------
>
> Key: CURATOR-332
> URL: https://issues.apache.org/jira/browse/CURATOR-332
> Project: Apache Curator
> Issue Type: Bug
> Components: Framework, Recipes
> Affects Versions: 3.1.0
> Reporter: Jordan Zimmerman
> Assignee: Jordan Zimmerman
> Fix For: 3.2.0
>
>
> The WatcherRemoveCuratorFramework introduced in 3.0.0 doesn't track watchers
> correctly and can sometimes lose track of some watchers and, thus, not delete
> them when requested to. Examples:
> * Exists watchers stay set even when there is a NoNode exception
> * If a watcher is successfully set and then the same watcher is used during a
> network failure, WatcherRemoveCuratorFramework will clear the watcher
> internally.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)