[ 
http://issues.apache.org/jira/browse/BEANUTILS-245?page=comments#action_12431006
 ] 
            
Pawan Kumar Shrivastava commented on BEANUTILS-245:
---------------------------------------------------

As i see the List implementation...

calling set(index, Object) checks (index >= size) and throws 
IndexOutOfBoundsException.

but calling add(index, Object) checks (index > size || index < 0). So if index 
= size (means next item ONLY) then it adds this in the list.

Now i am using reflection to set the values but the problem i have, i am 
getting the values in a loop, which i want to set in the list serially. So if 
PropertyUtils uses add(index, Object), it can help in my problem. I am not sure 
if others have faced this problem.

Please let me know, if i am wrong anywhere in my assumptions OR there is some 
other good reason for using set() method which i am not able to see.

> Problem setting nested index property or combined property (with index 
> property)
> --------------------------------------------------------------------------------
>
>                 Key: BEANUTILS-245
>                 URL: http://issues.apache.org/jira/browse/BEANUTILS-245
>             Project: Commons BeanUtils
>          Issue Type: Bug
>    Affects Versions: 1.7.0 Release
>         Environment: Windows XP Professional, Java 5
>            Reporter: Pawan Kumar Shrivastava
>
> This is the specific problem, when you are setting a nested index property 
> i.e.  - 
> list1[0].value
> Now i have initialized list1 as = new ArrayList(). Obviously the size is 0. 
> So PropertyUtils uses List.set(index, value) method, which throws 
> IndexOutOfBoundsException as the size and index are same.
> I think it should check the index and size first and then decide whether to 
> call add(index, value) or set(index, value).
> Please let me know, if my understanding is wrong. One potential misuse i can 
> see is what if someone passes index 100. But not sure if this can be resolved 
> by somehow shrinking the list.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to