You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Doug Cutting (JIRA)" <ji...@apache.org> on 2011/09/21 00:53:08 UTC
[jira] [Updated] (AVRO-887) ReflectData.findField needs better
error message
[ https://issues.apache.org/jira/browse/AVRO-887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-887:
------------------------------
Fix Version/s: 1.6.0
Assignee: Doug Cutting
Status: Patch Available (was: Open)
I'll commit this tomorrow unless someone objects.
> ReflectData.findField needs better error message
> ------------------------------------------------
>
> Key: AVRO-887
> URL: https://issues.apache.org/jira/browse/AVRO-887
> Project: Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.5.3
> Reporter: Chris Wilkes
> Assignee: Doug Cutting
> Priority: Trivial
> Fix For: 1.6.0
>
> Attachments: AVRO-887.patch
>
> Original Estimate: 0.25h
> Remaining Estimate: 0.25h
>
> In this method:
> Field findField(Class c, String name)
> a loop is done over c, replacing it each time with c = c.getSuperClass() and exiting if null. This means that at the end of the loop c will always be null. The exception message is then always
> No field named XXX in null
> The fix is trivial:
> private static Field findField(Class c, String name) {
> Class originalClass = c;
> do {
> try {
> Field f = c.getDeclaredField(name);
> f.setAccessible(true);
> return f;
> } catch (NoSuchFieldException e) {}
> c = c.getSuperclass();
> } while (c != null);
> throw new AvroRuntimeException("No field named "+name+" in: "+originalClass);
> }
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira