commons-issues mailing list archives

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

     [ https://issues.apache.org/jira/browse/BEANUTILS-368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Niall Pemberton resolved BEANUTILS-368.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.8.2
         Assignee: Niall Pemberton

This is a regression introduced in BeanUtils 1.8.1 by the fix for BEANUTILS-345:

    http://svn.apache.org/viewvc?view=revision&revision=822308

BeanUtils 1.7.0 and 1.8.0 throw an IllegalArgumentException if the target is null. I am adding
a null check to the new line of code that was added for  EANUTILS-345

Thanks for reporting this, it should now be fixed:

    http://svn.apache.org/viewvc?view=revision&revision=834031

> 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
>            Assignee: Niall Pemberton
>            Priority: Critical
>             Fix For: 1.8.2
>
>
> 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