kezhuw commented on code in PR #396:
URL: https://github.com/apache/curator/pull/396#discussion_r1161251834


##########
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:
   `ModelSerializer.raw` is a interface variable which means that it is 
`public`. Before this pr, the behavior is that:
   * With `ModelSerializer.raw` or maybe other serializers that tolerate `null` 
input, `ModeledCacheListener.accept` will be called with `null` model.
   * With `JacksonModelSerializer` or maybe other serializers that do not 
tolerate `null` input, `ModeledCacheListener.handleException` will be called 
with exception from `ModelSerializer.deserialize`.
   
   To keep consistent with `NODE_ADDED` and `NODE_UPDATED`, I think all these 
methods `ModelSerializer.deserialize` and 
`ModeledCacheListener.accept/handleException` should not be called for 
intermediate nodes in case of `NODE_REMOVED`. `ModelSerializer` is an open 
interface, we should provide consistent behavior among `ModelSerializer.raw`, 
`JacksonModelSerializer` and possible others. It would be helpful if we can 
assert this in test.
   
   cc @Randgalt @Ryan0751 



-- 
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