You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Zoran Avtarovski (JIRA)" <ji...@apache.org> on 2009/06/23 07:50:43 UTC
[jira] Created: (WW-3166) The contains method of
org.apache.struts2.util.ContainUtil throws a NullPointerException if Obj1
contains a null element in an array
The contains method of org.apache.struts2.util.ContainUtil throws a NullPointerException if Obj1 contains a null element in an array
------------------------------------------------------------------------------------------------------------------------------------
Key: WW-3166
URL: https://issues.apache.org/struts/browse/WW-3166
Project: Struts 2
Issue Type: Bug
Components: Other
Affects Versions: 2.1.7, 2.1.6
Environment: All
Reporter: Zoran Avtarovski
Priority: Trivial
The code for dealing with an array in the contains class needs to be swapped to prevent a NPE. The solution is trivial and involves swapping the order of the equals test for Arrays to be inline with that used for Iterable.
Currently the code is :
...else if (obj1.getClass().isArray()) {
for (int i = 0; i < Array.getLength(obj1); i++) {
Object value = null;
value = Array.get(obj1, i);
if (value.equals(obj2)) { // throws NPE if array contains null element
//log.debug("obj1 is an array and contains obj2");
return true;
}
}
}
When it should be :
...else if (obj1.getClass().isArray()) {
for (int i = 0; i < Array.getLength(obj1); i++) {
Object value = null;
value = Array.get(obj1, i);
if (obj2.equals(value)) { // change the order of the equals test to prevent NPE
//log.debug("obj1 is an array and contains obj2");
return true;
}
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WW-3166) The contains method of
org.apache.struts2.util.ContainUtil throws a NullPointerException if Obj1
contains a null element in an array
Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-3166?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Musachy Barroso resolved WW-3166.
---------------------------------
Resolution: Fixed
fixed in trunk, thanks for the patch
> The contains method of org.apache.struts2.util.ContainUtil throws a NullPointerException if Obj1 contains a null element in an array
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WW-3166
> URL: https://issues.apache.org/struts/browse/WW-3166
> Project: Struts 2
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.1.6, 2.1.7
> Environment: All
> Reporter: Zoran Avtarovski
> Priority: Trivial
> Fix For: 2.1.8
>
>
> The code for dealing with an array in the contains class needs to be swapped to prevent a NPE. The solution is trivial and involves swapping the order of the equals test for Arrays to be inline with that used for Iterable.
> Currently the code is :
> ...else if (obj1.getClass().isArray()) {
> for (int i = 0; i < Array.getLength(obj1); i++) {
> Object value = null;
> value = Array.get(obj1, i);
> if (value.equals(obj2)) { // throws NPE if array contains null element
> //log.debug("obj1 is an array and contains obj2");
> return true;
> }
> }
> }
> When it should be :
> ...else if (obj1.getClass().isArray()) {
> for (int i = 0; i < Array.getLength(obj1); i++) {
> Object value = null;
> value = Array.get(obj1, i);
> if (obj2.equals(value)) { // change the order of the equals test to prevent NPE
> //log.debug("obj1 is an array and contains obj2");
> return true;
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WW-3166) The contains method of
org.apache.struts2.util.ContainUtil throws a NullPointerException if Obj1
contains a null element in an array
Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-3166?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wes Wannemacher updated WW-3166:
--------------------------------
Fix Version/s: 2.1.8
appears trivial, we'll squeeze it into the next release
> The contains method of org.apache.struts2.util.ContainUtil throws a NullPointerException if Obj1 contains a null element in an array
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WW-3166
> URL: https://issues.apache.org/struts/browse/WW-3166
> Project: Struts 2
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.1.6, 2.1.7
> Environment: All
> Reporter: Zoran Avtarovski
> Priority: Trivial
> Fix For: 2.1.8
>
>
> The code for dealing with an array in the contains class needs to be swapped to prevent a NPE. The solution is trivial and involves swapping the order of the equals test for Arrays to be inline with that used for Iterable.
> Currently the code is :
> ...else if (obj1.getClass().isArray()) {
> for (int i = 0; i < Array.getLength(obj1); i++) {
> Object value = null;
> value = Array.get(obj1, i);
> if (value.equals(obj2)) { // throws NPE if array contains null element
> //log.debug("obj1 is an array and contains obj2");
> return true;
> }
> }
> }
> When it should be :
> ...else if (obj1.getClass().isArray()) {
> for (int i = 0; i < Array.getLength(obj1); i++) {
> Object value = null;
> value = Array.get(obj1, i);
> if (obj2.equals(value)) { // change the order of the equals test to prevent NPE
> //log.debug("obj1 is an array and contains obj2");
> return true;
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.