[jira] Created: (COLLECTIONS-304) SetUniqueList set method use corrupts uniqness

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (COLLECTIONS-304) SetUniqueList set method use corrupts uniqness

ASF GitHub Bot (Jira)
SetUniqueList set method use corrupts uniqness
----------------------------------------------

                 Key: COLLECTIONS-304
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-304
             Project: Commons Collections
          Issue Type: Bug
    Affects Versions: 3.2
         Environment: JDK 1.6/Windows/Eclipse Ganymede
            Reporter: Rafał Figas


When set method is used to put element (Strawberry) on list, then it is possible to add the same element (Strawberry) with add method. Also you cannot add element (Lemon) that has been once removed with set method. Reproduction code below:


List<String> list = new LinkedList<String>();
SetUniqueList decoratedList = SetUniqueList.decorate(list);

decoratedList.add("Apple");
decoratedList.add("Lemon");
decoratedList.add("Orange");

System.out.println(decoratedList.toString());

decoratedList.set(1, "Strawberry");

System.out.println(decoratedList.toString());

decoratedList.add(1, "Strawberry");

System.out.println(decoratedList.toString());

decoratedList.add(1, "Lemon");

System.out.println(decoratedList.toString());


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

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (COLLECTIONS-304) SetUniqueList set method use corrupts uniqness

ASF GitHub Bot (Jira)

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

Henri Yandell updated COLLECTIONS-304:
--------------------------------------

    Fix Version/s: 3.3

> SetUniqueList set method use corrupts uniqness
> ----------------------------------------------
>
>                 Key: COLLECTIONS-304
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-304
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: JDK 1.6/Windows/Eclipse Ganymede
>            Reporter: Rafał Figas
>             Fix For: 3.3
>
>
> When set method is used to put element (Strawberry) on list, then it is possible to add the same element (Strawberry) with add method. Also you cannot add element (Lemon) that has been once removed with set method. Reproduction code below:
> List<String> list = new LinkedList<String>();
> SetUniqueList decoratedList = SetUniqueList.decorate(list);
> decoratedList.add("Apple");
> decoratedList.add("Lemon");
> decoratedList.add("Orange");
> System.out.println(decoratedList.toString());
> decoratedList.set(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Lemon");
> System.out.println(decoratedList.toString());

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

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (COLLECTIONS-304) SetUniqueList set method use corrupts uniqness

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Bjorn Townsend updated COLLECTIONS-304:
---------------------------------------

    Attachment: Commons-304-test.diff

Here's a JUnit test reproducing this. Nice catch. :)

> SetUniqueList set method use corrupts uniqness
> ----------------------------------------------
>
>                 Key: COLLECTIONS-304
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-304
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: JDK 1.6/Windows/Eclipse Ganymede
>            Reporter: Rafał Figas
>             Fix For: 3.3
>
>         Attachments: Commons-304-test.diff
>
>
> When set method is used to put element (Strawberry) on list, then it is possible to add the same element (Strawberry) with add method. Also you cannot add element (Lemon) that has been once removed with set method. Reproduction code below:
> List<String> list = new LinkedList<String>();
> SetUniqueList decoratedList = SetUniqueList.decorate(list);
> decoratedList.add("Apple");
> decoratedList.add("Lemon");
> decoratedList.add("Orange");
> System.out.println(decoratedList.toString());
> decoratedList.set(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Lemon");
> System.out.println(decoratedList.toString());

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

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (COLLECTIONS-304) SetUniqueList set method use corrupts uniqness

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Henri Yandell updated COLLECTIONS-304:
--------------------------------------

    Attachment: COLLECTIONS-304.patch

Adding a fix for this issue, with a slight tweak on Bjorn's unit test.

> SetUniqueList set method use corrupts uniqness
> ----------------------------------------------
>
>                 Key: COLLECTIONS-304
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-304
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: JDK 1.6/Windows/Eclipse Ganymede
>            Reporter: Rafał Figas
>             Fix For: 3.3
>
>         Attachments: COLLECTIONS-304.patch, Commons-304-test.diff
>
>
> When set method is used to put element (Strawberry) on list, then it is possible to add the same element (Strawberry) with add method. Also you cannot add element (Lemon) that has been once removed with set method. Reproduction code below:
> List<String> list = new LinkedList<String>();
> SetUniqueList decoratedList = SetUniqueList.decorate(list);
> decoratedList.add("Apple");
> decoratedList.add("Lemon");
> decoratedList.add("Orange");
> System.out.println(decoratedList.toString());
> decoratedList.set(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Lemon");
> System.out.println(decoratedList.toString());

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

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (COLLECTIONS-304) SetUniqueList set method use corrupts uniqness

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Henri Yandell closed COLLECTIONS-304.
-------------------------------------

    Resolution: Fixed

svn ci -m "Applying Bjorn Townsend's unit test and my fix for COLLECTIONS-304 - fixing SetUniqueList so the set method doesn't let the uniqueness get out of sync"
Sending        src/java/org/apache/commons/collections/list/SetUniqueList.java
Sending        src/test/org/apache/commons/collections/list/TestSetUniqueList.java
Transmitting file data ..
Committed revision 711591.

> SetUniqueList set method use corrupts uniqness
> ----------------------------------------------
>
>                 Key: COLLECTIONS-304
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-304
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: JDK 1.6/Windows/Eclipse Ganymede
>            Reporter: Rafał Figas
>             Fix For: 3.3
>
>         Attachments: COLLECTIONS-304.patch, Commons-304-test.diff
>
>
> When set method is used to put element (Strawberry) on list, then it is possible to add the same element (Strawberry) with add method. Also you cannot add element (Lemon) that has been once removed with set method. Reproduction code below:
> List<String> list = new LinkedList<String>();
> SetUniqueList decoratedList = SetUniqueList.decorate(list);
> decoratedList.add("Apple");
> decoratedList.add("Lemon");
> decoratedList.add("Orange");
> System.out.println(decoratedList.toString());
> decoratedList.set(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Strawberry");
> System.out.println(decoratedList.toString());
> decoratedList.add(1, "Lemon");
> System.out.println(decoratedList.toString());

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