diff --git a/config/src/main/java/com/typesafe/config/impl/ConfigBeanImpl.java b/config/src/main/java/com/typesafe/config/impl/ConfigBeanImpl.java index 2b9cf5c60..902311359 100644 --- a/config/src/main/java/com/typesafe/config/impl/ConfigBeanImpl.java +++ b/config/src/main/java/com/typesafe/config/impl/ConfigBeanImpl.java @@ -285,7 +285,10 @@ private static boolean hasAtLeastOneBeanProperty(Class clazz) { private static boolean isOptionalProperty(Class beanClass, PropertyDescriptor beanProp) { Field field = getField(beanClass, beanProp.getName()); - return field != null ? field.getAnnotationsByType(Optional.class).length > 0 : beanProp.getReadMethod().getAnnotationsByType(Optional.class).length > 0; + return field != null + ? field.getAnnotationsByType(Optional.class).length > 0 + || beanProp.getReadMethod().getAnnotationsByType(Optional.class).length > 0 + : beanProp.getReadMethod().getAnnotationsByType(Optional.class).length > 0; } private static Field getField(Class beanClass, String fieldName) {