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/14 18:50:34 UTC

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

martin-g commented on a change in pull request #1335:
URL: https://github.com/apache/avro/pull/1335#discussion_r708542212



##########
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:
       `... in field name` sounds like something is wrong in the field's name.
   IMO it would be clearer if the field name is wrapped in single quotes: `... in field 'name'`




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