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
Priority: Trivial
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