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


##########
curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java:
##########
@@ -181,6 +184,72 @@ public void testAccessCacheDirectly()
         }
     }
 
+    // Verify the CachedModeledFramework does not attempt to deserialize empty 
ZNodes on deletion.
+    // See: CURATOR-609
+    @Test
+    public void testEmptyNodeDeserialization()
+    {
+        // The sub-path is the ZNode that will be removed that does not 
contain a model. This model with no data
+        // should not result in attempt to deserialize.
+        final String subPath = modelSpec.path().toString() + "/sub";
+
+        final String firstModelPath = subPath + "/first";
+        final String secondModelPath = subPath + "/second";
+
+        CountDownLatch latch = new CountDownLatch(1);
+
+        final AtomicBoolean caughtException = new AtomicBoolean(false);
+
+        // Create a custom listener to signal the end of the test and ensure 
no exceptions are thrown.
+        final ModeledCacheListener<TestModel> listener = new 
ModeledCacheListener<TestModel>() {
+            @Override
+            public void accept(Type t, ZPath p, Stat s, TestModel m)
+            {
+                if (t == ModeledCacheListener.Type.NODE_ADDED && 
p.toString().equals(secondModelPath)) {
+                    latch.countDown();
+                }
+            }
+
+            public void handleException(Exception e) {
+                System.err.printf("Caught unexpected exception %s%n", e);

Review Comment:
   This is unnecessary. Or you could try `AtomicReference<Exception>` and 
`assertNull` ? This will give us cue about failure reason without resort to 
`printf`.



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