You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Pawan Kumar Shrivastava (JIRA)" <ji...@apache.org> on 2006/08/04 14:57:13 UTC
[jira] Created: (BEANUTILS-245) Problem setting nested index
property or combined property (with index property)
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (BEANUTILS-245) Problem setting nested index
property or combined property (with index property)
Posted by "Pawan Kumar Shrivastava (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/BEANUTILS-245?page=comments#action_12431012 ]
Pawan Kumar Shrivastava commented on BEANUTILS-245:
---------------------------------------------------
CAN some one please close this as this is NOT really a BUG...
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (BEANUTILS-245) Problem setting nested index
property or combined property (with index property)
Posted by "Pawan Kumar Shrivastava (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/BEANUTILS-245?page=comments#action_12431011 ]
Pawan Kumar Shrivastava commented on BEANUTILS-245:
---------------------------------------------------
I think, i can see now why its not using add() method. Consider there is no item in the list and so if Property Utils uses add(), it will not know what type of Obejct is need to added in the List.
E.g. if i pass PropertyUtils.setNestedProperty(bean, "list[0].id", "1")
and if PropertyUtils uses add method then it need to invoke something like this -
bean.getList().add(0, new ListElement())
bean.getList().get(0).setId("1")
But PropertyUtils can not know, what instance it has to put in the List at the first place.
So i think i shall be using something like -
PropertyUtils.getNestedProperty(bean, "list")
Then chek what i get back and if its a list then check the size and if its 0 or equal to the index where i want to set the value, then add the item in the list and then invoke PropertyUtils.setNestedProperty(bean, "list[0].id", "1");
Thanks
Pawan
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Closed: (BEANUTILS-245) Problem setting nested index
property or combined property (with index property)
Posted by "Simon Kitching (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/BEANUTILS-245?page=all ]
Simon Kitching closed BEANUTILS-245.
------------------------------------
Resolution: Invalid
Closing as requested by original poster.
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (BEANUTILS-245) Problem setting nested index
property or combined property (with index property)
Posted by "Pawan Kumar Shrivastava (JIRA)" <ji...@apache.org>.
[ 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org