Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.8.1
-
None
-
JDK 1.6
Description
There is a NullPointerException in the method BeanUtilsBeans.setProperty(Object bean, String name, Object value) method:
java.lang.NullPointerException
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:930)
The problem is, that few rows earlear the target may be null:
target = getPropertyUtils().getProperty(target, resolver.next(name)); // NOTE, the result may be NULL.
In such case, the condition at line 930
} else if (target.getClass().isArray() && index >= 0) {
will race a NullPointerException. In the old 1.7.0 version there has been no such condition or has been executed later...
Proposed FIX: Please add at new line, which checks the "target"
target = getPropertyUtils().getProperty(target, resolver.next(name)); // NOTE, the result may be NULL.
if (target == null)
NOTE. Such check may be added also to the other similar methods, like BeanUtilsBean.copyProperty().
Regards
Peter
Attachments
Issue Links
- relates to
-
BEANUTILS-345 BeanUtilsBean.setProperty does not handle some kind of nested properties
- Closed