You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by "Ryan0751 (via GitHub)" <gi...@apache.org> on 2023/04/07 15:05:20 UTC

[GitHub] [curator] Ryan0751 commented on a diff in pull request #396: CURATOR-609 - ModeledCache attempts to deserialize empty ZNodes on deletion, resulting in exceptions

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


##########
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:
   I might help to mention the use case.
   
   Imagine that we have a model called Widget.
   
   In our application we group Widgets under sub-groups, and we can have many Widgets (100k+).  
   
   As such, we structured ZooKeeper as follows:
   /widget/<sub-group A>/<widget 1>
   /widget/<sub-group B>/<widget 2>
   
   We want to use ModeledFramework to deserialize widgets, however if we encounter a sub-group ZNode that is part of the ZNode, we'd like to just ignore that rather than cause serialization exceptions.
   
   I will have a look at ModelSerializer.raw and where it fits in here.
   
   



-- 
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: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org