You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Daniel Baldes (JIRA)" <ji...@apache.org> on 2009/02/24 16:29:45 UTC

[jira] Created: (WW-3010) s:iterator fails to iterate over collections containing null

s:iterator fails to iterate over collections containing null
------------------------------------------------------------

                 Key: WW-3010
                 URL: https://issues.apache.org/struts/browse/WW-3010
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.0.14
         Environment: any
            Reporter: Daniel Baldes


When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:

            if ((id != null) && (currentValue != null)) {
                //pageContext.setAttribute(id, currentValue);
                //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
                stack.getContext().put(id, currentValue);
            }

Expected behaviour: just iterate over the null values as a plain java iterator would.

If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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


[jira] Commented: (WW-3010) s:iterator fails to iterate over collections containing null

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45961#action_45961 ] 

Dave Newton commented on WW-3010:
---------------------------------

But apps coded to expect "correct" behavior will break, because "correct" behavior isn't what actually happens. Code changes that break existing behavior, "correct" or not, can't just be thrown in willy-nilly, "dangerous mentality" or not.

> s:iterator fails to iterate over collections containing null
> ------------------------------------------------------------
>
>                 Key: WW-3010
>                 URL: https://issues.apache.org/struts/browse/WW-3010
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>         Environment: any
>            Reporter: Daniel Baldes
>
> When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:
>             if ((id != null) && (currentValue != null)) {
>                 //pageContext.setAttribute(id, currentValue);
>                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
>                 stack.getContext().put(id, currentValue);
>             }
> Expected behaviour: just iterate over the null values as a plain java iterator would.
> If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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


[jira] Commented: (WW-3010) s:iterator fails to iterate over collections containing null

Posted by "Daniel Baldes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45967#action_45967 ] 

Daniel Baldes commented on WW-3010:
-----------------------------------

Well, every bug is bad behavior where someone could possibly rely on... of course there are bugs where the "incorrectness" of the behavior is less obvious, but I don't see why this just-plain-wrong behavior shouldn't be fixed right away. Whatever.

> s:iterator fails to iterate over collections containing null
> ------------------------------------------------------------
>
>                 Key: WW-3010
>                 URL: https://issues.apache.org/struts/browse/WW-3010
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>         Environment: any
>            Reporter: Daniel Baldes
>
> When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:
>             if ((id != null) && (currentValue != null)) {
>                 //pageContext.setAttribute(id, currentValue);
>                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
>                 stack.getContext().put(id, currentValue);
>             }
> Expected behaviour: just iterate over the null values as a plain java iterator would.
> If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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


[jira] Issue Comment Edited: (WW-3010) s:iterator fails to iterate over collections containing null

Posted by "Mark B (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45957#action_45957 ] 

Mark B edited comment on WW-3010 at 4/15/09 3:31 PM:
-----------------------------------------------------

Musachy, I think this is a dangerous mentality. There are probably many more apps coded expecting correct behavior than coded to rely on incorrect behavior.

If we are iterating over a list whose first element is a null, we should get a null as the first value.

      was (Author: z5h):
    Musachy, I think this is a dangerous mentality. There are probably many more apps coded expecting correct behavior than coded to rely on incorrect behavior.

If we are iterating over a list whose first element is a null, we should get a null as the first value. End of discussion.
  
> s:iterator fails to iterate over collections containing null
> ------------------------------------------------------------
>
>                 Key: WW-3010
>                 URL: https://issues.apache.org/struts/browse/WW-3010
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>         Environment: any
>            Reporter: Daniel Baldes
>
> When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:
>             if ((id != null) && (currentValue != null)) {
>                 //pageContext.setAttribute(id, currentValue);
>                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
>                 stack.getContext().put(id, currentValue);
>             }
> Expected behaviour: just iterate over the null values as a plain java iterator would.
> If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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


[jira] Commented: (WW-3010) s:iterator fails to iterate over collections containing null

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45637#action_45637 ] 

Musachy Barroso commented on WW-3010:
-------------------------------------

I agree the current value ("id") should be set to null, but changing would potentially break current apps, so this should probably be fixed for 2.2 or so.

> s:iterator fails to iterate over collections containing null
> ------------------------------------------------------------
>
>                 Key: WW-3010
>                 URL: https://issues.apache.org/struts/browse/WW-3010
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>         Environment: any
>            Reporter: Daniel Baldes
>
> When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:
>             if ((id != null) && (currentValue != null)) {
>                 //pageContext.setAttribute(id, currentValue);
>                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
>                 stack.getContext().put(id, currentValue);
>             }
> Expected behaviour: just iterate over the null values as a plain java iterator would.
> If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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


[jira] Commented: (WW-3010) s:iterator fails to iterate over collections containing null

Posted by "Mark B (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45985#action_45985 ] 

Mark B commented on WW-3010:
----------------------------

It is generally understood, in the programming world, that users of undocumented "features" are absolutely free to use said features but that they do so at their own peril.

At worst this is a bug, and should be fixed. 
At best, an "undocumented feature". (And that would be very hard to argue as this is documented as an iterator, a notion that transcends APIs and programming languages.) 

In any case, when it finally works according to the documentation no good developer should be surprised, and no well tested or written app should stop working. 

> s:iterator fails to iterate over collections containing null
> ------------------------------------------------------------
>
>                 Key: WW-3010
>                 URL: https://issues.apache.org/struts/browse/WW-3010
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>         Environment: any
>            Reporter: Daniel Baldes
>
> When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:
>             if ((id != null) && (currentValue != null)) {
>                 //pageContext.setAttribute(id, currentValue);
>                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
>                 stack.getContext().put(id, currentValue);
>             }
> Expected behaviour: just iterate over the null values as a plain java iterator would.
> If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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


[jira] Commented: (WW-3010) s:iterator fails to iterate over collections containing null

Posted by "Mark B (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45957#action_45957 ] 

Mark B commented on WW-3010:
----------------------------

Musachy, I think this is a dangerous mentality. There are probably many more apps coded expecting correct behavior than coded to rely on incorrect behavior.

If we are iterating over a list whose first element is a null, we should get a null as the first value. End of discussion.

> s:iterator fails to iterate over collections containing null
> ------------------------------------------------------------
>
>                 Key: WW-3010
>                 URL: https://issues.apache.org/struts/browse/WW-3010
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>         Environment: any
>            Reporter: Daniel Baldes
>
> When using the struts2 taglib's iterator tag to iterate over a collection which contains nulls, the current value ("id") is not set to null, but to the value it had in the last iteration before. This behaviour is explicitly coded without any obvious reason. See IteratorComponent.java from line 219:
>             if ((id != null) && (currentValue != null)) {
>                 //pageContext.setAttribute(id, currentValue);
>                 //pageContext.setAttribute(id, currentValue, PageContext.REQUEST_SCOPE);
>                 stack.getContext().put(id, currentValue);
>             }
> Expected behaviour: just iterate over the null values as a plain java iterator would.
> If nulls are forbidden for some important reason, it should throw an execption, but not return a wrong value.

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