Ryan0751 commented on code in PR #396:
URL: https://github.com/apache/curator/pull/396#discussion_r1161906217
##########
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:
Done. I had to do this as an AtomicBoolean again, as again the exception
doesn't otherwise bubble up and fail the test.
--
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]