commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Fassev (JIRA)" <j...@apache.org>
Subject [jira] Created: (BEANUTILS-368) NullPointerException in BeanUtilsBean .setProperty(), line: 930
Date Mon, 09 Nov 2009 11:30:32 GMT
NullPointerException in BeanUtilsBean .setProperty(), line: 930
---------------------------------------------------------------

                 Key: BEANUTILS-368
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-368
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: Bean / Property Utils
    Affects Versions: 1.8.1
         Environment: JDK 1.6
            Reporter: Peter Fassev
            Priority: Critical


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) {
            return;
        }

NOTE. Such check may be added also to the other similar methods, like BeanUtilsBean.copyProperty().

Regards
Peter


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message