Ryan0751 commented on a change in pull request #396:
URL: https://github.com/apache/curator/pull/396#discussion_r691178552



##########
File path: 
curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ModeledCacheImpl.java
##########
@@ -188,9 +188,18 @@ private void internalChildEvent(TreeCacheEvent event)
         {
             ZPath path = ZPath.parse(event.getData().getPath());
             Entry<T> entry = entries.remove(path);
-            T model = (entry != null) ? entry.model : 
serializer.deserialize(event.getData().getData());
-            Stat stat = (entry != null) ? entry.stat : 
event.getData().getStat();
-            accept(ModeledCacheListener.Type.NODE_REMOVED, path, stat, model);
+            T model = null;
+            if (entry != null) {
+                model = entry.model;
+            }
+            else if (event.getData().getData() != null) {
+                model = serializer.deserialize(event.getData().getData());
+            }
+            if (model != null) {
+                Stat stat = (entry != null) ? entry.stat : 
event.getData().getStat();
+                accept(ModeledCacheListener.Type.NODE_REMOVED, path, stat, 
model);

Review comment:
       You are correct, this change would alter the behavior in that 
`accept(ModeledCacheListener.NODE_REMOVED... ` would not be called if the node 
in question doesn't contain any data (ie, a valid Model).
   
   However, I'm not sure this is a bad thing.  If you look above in the code at 
the implementation for the NODE_ADDED and NODE_UPDATE case, the `accept()` 
method is also not called if the ZNode in question does not contain any data.
   
   Unit testing doesn't seem to cover this use case either way (the tests all 
passed without any modification).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to