You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Douglas Britsch (JIRA)" <ji...@apache.org> on 2010/05/14 20:44:42 UTC

[jira] Updated: (AVRO-542) NPE in ReflectData

     [ https://issues.apache.org/jira/browse/AVRO-542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Douglas Britsch updated AVRO-542:
---------------------------------

    Description: 
On line 253 of ReflectData.java the package is retrieved with:

String space = c.getPackage().getName();

getPackage is documented to be able to return null, and in practice does with generated classes and in certain child classloader scenarios. A safer alternative would be to derive the package by parsing the string returned from the class's name:

String space = c.getName().substring(0, name.lastIndexOf('.'); 

Thanks

  was:
On line 253 of ReflectData.java the package is retrieved with:

String space = c.getPackage().getName();

getPackage is documented to be able to return null, and in practice does with generated classes and in certain child classloader scenarios. A safer alternative would be to derive the package by passing the string returned from the class's name:

String space = c.getName().substring(0, name.lastIndexOf('.'); 

Thanks


> NPE in ReflectData 
> -------------------
>
>                 Key: AVRO-542
>                 URL: https://issues.apache.org/jira/browse/AVRO-542
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.3.2
>         Environment: Java
>            Reporter: Douglas Britsch
>
> On line 253 of ReflectData.java the package is retrieved with:
> String space = c.getPackage().getName();
> getPackage is documented to be able to return null, and in practice does with generated classes and in certain child classloader scenarios. A safer alternative would be to derive the package by parsing the string returned from the class's name:
> String space = c.getName().substring(0, name.lastIndexOf('.'); 
> Thanks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.