Skip to content

Commit

Permalink
Fix for issue #447. Instead of ignoring fields without a proper gette…
Browse files Browse the repository at this point in the history
…r/setter, avoid the NPE checking first that there's a field to work with.
  • Loading branch information
tzarouali committed Feb 20, 2017
1 parent 4d98a00 commit 870dd28
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ public static <T> T createInternal(Config config, Class<T> clazz) {
try {
List<PropertyDescriptor> beanProps = new ArrayList<PropertyDescriptor>();
for (PropertyDescriptor beanProp : beanInfo.getPropertyDescriptors()) {
if (beanProp.getReadMethod() == null
|| beanProp.getWriteMethod() == null
|| getField(clazz, beanProp.getName()) == null) {
if (beanProp.getReadMethod() == null || beanProp.getWriteMethod() == null) {
continue;
}
beanProps.add(beanProp);
Expand Down Expand Up @@ -279,7 +277,7 @@ private static boolean hasAtLeastOneBeanProperty(Class<?> clazz) {

private static boolean isOptionalProperty(Class beanClass, PropertyDescriptor beanProp) {
Field field = getField(beanClass, beanProp.getName());
return (field.getAnnotationsByType(Optional.class).length > 0);
return field != null && (field.getAnnotationsByType(Optional.class).length > 0);
}

private static Field getField(Class beanClass, String fieldName) {
Expand Down

0 comments on commit 870dd28

Please sign in to comment.