You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Lars Francke (JIRA)" <ji...@apache.org> on 2015/04/01 10:30:53 UTC

[jira] [Commented] (AVRO-1655) RecordSchema#fieldsToJson can throw NullPointerException

    [ https://issues.apache.org/jira/browse/AVRO-1655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14390214#comment-14390214 ] 

Lars Francke commented on AVRO-1655:
------------------------------------

Thanks Ryan, point taken.

But I think these two are complementary for now. The earliest you could remove the existing ones would be 2.x or 1.8.x I guess (2 would be following SemVer rules).

So people will be able to construct these Schemas at least for all following 1.7.x releases and maybe longer. This code could be removed later of course but for now it'll make usage way easier for Spark/Scala shell users.

> RecordSchema#fieldsToJson can throw NullPointerException
> --------------------------------------------------------
>
>                 Key: AVRO-1655
>                 URL: https://issues.apache.org/jira/browse/AVRO-1655
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.7.7
>            Reporter: Lars Francke
>            Assignee: Lars Francke
>         Attachments: AVRO-1655.1.patch
>
>
> The code just does
> {code}
>       for (Field f : fields) {
> {code}
> without ever checking if fields is set. There is a {{createRecord}} version that does not take fields so this can be empty. This is especially annoying within the Scala/Spark REPL as that immediately prints out the result of everything you type so it calls {{toString}} which then fails and that even leaves the object unset in the REPL.
> I'll attach a patch that checks whether {{fields}} is null.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)