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


##########
curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java:
##########
@@ -181,6 +184,88 @@ public void testAccessCacheDirectly()
         }
     }
 
+    // Verify the CachedModeledFramework does not attempt to deserialize empty 
ZNodes on deletion using the Jackson
+    // model serializer.
+    // See: CURATOR-609
+    @Test
+    public void testEmptyNodeJacksonDeserialization()
+    {
+        final TestModel model = new TestModel("a", "b", "c", 20, 
BigInteger.ONE);
+        verifyEmptyNodeDeserialization(model, modelSpec);
+    }
+
+    // Verify the CachedModeledFramework does not attempt to deserialize empty 
ZNodes on deletion using the raw
+    // model serializer.
+    // See: CURATOR-609
+    @Test
+    public void testEmptyNodeRawDeserialization()
+    {
+        final byte[] byteModel = {0x01, 0x02, 0x03};
+        final ModelSpec<byte[]> byteModelSpec = ModelSpec.builder(path, 
ModelSerializer.raw).build();
+        verifyEmptyNodeDeserialization(byteModel, byteModelSpec);
+    }
+
+    private <T> void verifyEmptyNodeDeserialization(T model, ModelSpec<T> 
parentModelSpec)
+    {
+        // The sub-path is the ZNode that will be removed that does not 
contain any model data. Their should be no
+        // attempt to deserialize this empty ZNode.
+        final String subPath = parentModelSpec.path().toString() + "/sub";
+
+        final String testModelPath = subPath + "/test";
+        final String signalModelPath = subPath + "/signal";
+
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        final AtomicReference<Exception> caughtException = new 
AtomicReference<>(null);
+
+        // Create a custom listener to signal the end of the test and ensure 
that nothing is thrown.
+        final ModeledCacheListener<T> listener = new ModeledCacheListener<T>() 
{
+            @Override
+            public void accept(Type t, ZPath p, Stat s, T m)

Review Comment:
   How about add a assert for non null model ? This way both the two tests will 
fail without this patch.
   * `testEmptyNodeRawDeserialization` fails as it receive `null` input.
   * `testEmptyNodeJacksonDeserialization` fails as deserialization failure due 
to `null` data.



##########
curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestModeledFrameworkBase.java:
##########
@@ -48,8 +50,8 @@ public void setup() throws Exception
         rawClient.start();
         async = AsyncCuratorFramework.wrap(rawClient);
 
-        JacksonModelSerializer<TestModel> serializer = 
JacksonModelSerializer.build(TestModel.class);
-        JacksonModelSerializer<TestNewerModel> newSerializer = 
JacksonModelSerializer.build(TestNewerModel.class);
+        serializer = JacksonModelSerializer.build(TestModel.class);

Review Comment:
   Unreleated change ?



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