Github user Randgalt commented on a diff in the pull request:
https://github.com/apache/curator/pull/154#discussion_r64830951
--- 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 --
Yeah, that's safer.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---