dajac commented on PR #12932:
URL: https://github.com/apache/kafka/pull/12932#issuecomment-1341640919

   > Can you add a test that the Invalid default for struct field message 
appears as expected when the default is set to something other than null? 
MessageDataGeneratorTest.java has some examples of tests like that
   
   That makes sense. Added tests.
   
   > The other test that I really want is a test that a tagged nullable struct 
will be correctly ignored by code prior to this PR. Unfortunately I don't have 
a good suggestion for how to do that in junit or ducktape. Can you do some kind 
of manual test to ensure that this is the case?
   
   I did the following. With this PR, I used the following schema and code to 
serialize a message.
   
   ```
   {
     "name": "TestMessage",
     "type": "header",
     "validVersions": "0",
     "flexibleVersions": "0+",
     "fields": [
       { "name": "struct1", "type": "Struct", "versions": "0+", 
"nullableVersions": "0+", "default": "null",
         "tag": 1, "taggedVersions": "0+", "fields": [
           { "name": "int1", "type": "int32", "versions": "0+" }
         ]
       },
       { "name": "int0", "type": "int32", "versions": "0+", "tag": 0, 
"taggedVersions": "0+" }
     ]
   }
   ```
   
   ```
           TestMessageData.Struct struct = new TestMessageData.Struct()
               .setInt1(100);
           TestMessageData message = new TestMessageData()
               .setStruct1(struct)
               .setInt0(200);
   
           ByteBuffer buffer = MessageUtil.toByteBuffer(message, (short) 0);
           FileChannel fc = new 
FileOutputStream("/tmp/test-message").getChannel();
           fc.write(buffer);
           fc.close();
   ```
   
   Then, with trunk, I used the following schema and code to validate.
   
   ```
   {
     "name": "TestMessage",
     "type": "header",
     "validVersions": "0",
     "flexibleVersions": "0+",
     "fields": [
       { "name": "int0", "type": "int32", "versions": "0+", "tag": 0, 
"taggedVersions": "0+" }
     ]
   }
   ```
   
   ```
           FileChannel fc = new 
FileInputStream("/tmp/test-message").getChannel();
           ByteBuffer buffer = ByteBuffer.allocate((int) fc.size());
           fc.read(buffer);
           fc.close();
           buffer.flip();
   
           TestMessageData message = new TestMessageData();
           message.read(new ByteBufferAccessor(buffer), (short) 0);
   
           assertEquals(200, message.int0());
           assertEquals(1, message.unknownTaggedFields().size());
   ```
   
   That worked as expected.


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