You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2021/09/15 07:45:24 UTC

[GitHub] [avro] gkomlossi commented on a change in pull request #1335: AVRO-3206 Provide more information in the serialization error messageā€¦

gkomlossi commented on a change in pull request #1335:
URL: https://github.com/apache/avro/pull/1335#discussion_r708926178



##########
File path: lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificDatumWriter.java
##########
@@ -50,4 +52,26 @@ public void testResolveUnion() throws IOException {
     assertEquals(expectedJson, out.toString("UTF-8"));
   }
 
+  @Test
+  public void testIncompleteRecord() throws IOException {
+    final SpecificDatumWriter<TestRecord> writer = new SpecificDatumWriter<>();
+    Schema schema = TestRecord.SCHEMA$;
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    JsonEncoder encoder = EncoderFactory.get().jsonEncoder(schema, out);
+
+    writer.setSchema(schema);
+
+    TestRecord testRecord = new TestRecord();
+    testRecord.setKind(Kind.BAR);
+    testRecord.setHash(new MD5(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }));
+
+    try {
+      writer.write(testRecord, encoder);
+      fail("Exception not thrown");
+    } catch (NullPointerException e) {
+      assertTrue(e.getMessage().contains("null of string in field name"));

Review comment:
       Thanks a lot for taking a look and your suggestion. It would be clearer indeed. I've made a change for this.




-- 
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: issues-unsubscribe@avro.apache.org

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