You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by zz...@apache.org on 2013/05/02 03:48:29 UTC
git commit: fix listener leaking
Updated Branches:
refs/heads/master 4ebc0fad9 -> cec747d68
fix listener leaking
Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/cec747d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/cec747d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/cec747d6
Branch: refs/heads/master
Commit: cec747d68c5a13a827f35e25353a0ba003820942
Parents: 4ebc0fa
Author: zzhang <zz...@uci.edu>
Authored: Wed May 1 18:48:21 2013 -0700
Committer: zzhang <zz...@uci.edu>
Committed: Wed May 1 18:48:21 2013 -0700
----------------------------------------------------------------------
.../apache/helix/manager/zk/CallbackHandler.java | 20 ++++++++------
1 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/cec747d6/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
index 4265cc6..cfe40c1 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
@@ -112,14 +112,6 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
public void invoke(NotificationContext changeContext) throws Exception
{
- // remove this listener if path no longer exists after session expiry
- if (changeContext.getType() == Type.INIT && !_zkClient.exists(_path)) {
- logger.info("removing listener because path no longer exists. path: "
- + _path + ", listener: " + _listener);
- _manager.removeListener(_propertyKey, _listener);
- return;
- }
-
// This allows the listener to work with one change at a time
synchronized (_manager)
{
@@ -458,7 +450,17 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
if (parentPath != null && parentPath.startsWith(_path))
{
NotificationContext changeContext = new NotificationContext(_manager);
- changeContext.setType(NotificationContext.Type.CALLBACK);
+
+ if (currentChilds == null) {
+ // parentPath has been removed
+ if (parentPath.equals(_path)) {
+ // _path has been removed, remove this listener
+ _manager.removeListener(_propertyKey, _listener);
+ }
+ changeContext.setType(NotificationContext.Type.FINALIZE);
+ } else {
+ changeContext.setType(NotificationContext.Type.CALLBACK);
+ }
invoke(changeContext);
}
}