[ 
https://issues.apache.org/jira/browse/AVRO-3206?focusedWorklogId=650956&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-650956
 ]

ASF GitHub Bot logged work on AVRO-3206:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Sep/21 07:45
            Start Date: 15/Sep/21 07:45
    Worklog Time Spent: 10m 
      Work Description: 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 650956)
    Time Spent: 0.5h  (was: 20m)

> Provide more information in serialization error messages in 
> SpecificDatumWriter
> -------------------------------------------------------------------------------
>
>                 Key: AVRO-3206
>                 URL: https://issues.apache.org/jira/browse/AVRO-3206
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.10.2
>            Reporter: Gyula Komlossi
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> In certain cases, when there is an error (like NPE, ClassCastException) in 
> the "*writeField*" method of the "*SpecificDatumWriter*" class, the thrown 
> exception doesn't contain the specific field causing the problem.
> Similarly as implemented in GenericDatumWriter, the same exceptions could be 
> caught and their message improved by adding the related field name causing 
> the problem.
> Currently, the message is like this:
> {code:java}
> java.lang.NullPointerException: null of string of 
> org.apache.avro.test.TestRecord
> {code}
> But with the improvement it would be:
> {code:java}
> java.lang.NullPointerException: null of string in field name of 
> org.apache.avro.test.TestRecord
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to