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

Oliver Zeigermann closed WICKET-3915.
-------------------------------------


Thanks, that fixes the bug!
                
> Inconsistent behavior id under special circumstances 
> -----------------------------------------------------
>
>                 Key: WICKET-3915
>                 URL: https://issues.apache.org/jira/browse/WICKET-3915
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.14, 1.4.15, 1.4.16, 1.4.17
>            Reporter: Oliver Zeigermann
>            Assignee: Igor Vaynberg
>             Fix For: 1.4.19
>
>
> When removing behaviors in org.apache.wicket.Component#removeBehavior under 
> special circumstances ids of existing behaviors can change causing 
> inconsistentencies. 
> Ids of behaviors are determined by their position inside an array. The error 
> occurs when you first remove a behavior in the middle of the array and then 
> eventually at the end. The problem is some code that tries to compact the 
> array under wrong assumpt when removing the last element in the array
> This is the code that displays it
>     DummyBehavior dummyBehavior = new DummyBehavior();
>     component.add(dummyBehavior);
>     DummyBehavior dummyBehavior2 = new DummyBehavior();
>     component.add(dummyBehavior2);
>     DummyBehavior dummyBehavior3 = new DummyBehavior();
>     component.add(dummyBehavior3);
>     DummyBehavior dummyBehavior4 = new DummyBehavior();
>     component.add(dummyBehavior4);
>     String callbackUrlBefore = dummyBehavior3.getCallbackUrl().toString();
>     component.remove(dummyBehavior2);
>     String callbackUrlAfter2 = dummyBehavior3.getCallbackUrl().toString();
>     Assert.assertEquals("Works fine", callbackUrlBefore, callbackUrlAfter2);
>     component.remove(dummyBehavior4);
>     String callbackUrlAfter4 = dummyBehavior3.getCallbackUrl().toString();
>     Assert.assertEquals("Bug in Wicket!!!", callbackUrlBefore, 
> callbackUrlAfter4);
> You can fix this by simple commenting out the compacting code. And live with 
> an array that may grow a bit. 
> This is the orginal code in org.apache.wicket.Component#removeBehavior now 
> commented out
>           // if (o instanceof IRequestListener) {
>           // // this was a listener which mightve caused holes in the array, 
> see if we
>           // // can clean them up. notice: at this point we already know 
> there are no
>           // // listeners that can be affected by index change downstream 
> because this is
>           // // the last one in the array
>           // for (int j = i - 1; j >= start; j--) {
>           // if (data_get(j) == null) {
>           // data_remove(j);
>           // }
>           // }
>           // }
> Due to some larger refactoring this code does not seem to be present in 1.5.x 
> any more.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to