You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/04/19 13:35:00 UTC

[jira] [Commented] (WICKET-6877) Removing component's MetaData during detach phase from within a Behavior causes issue

    [ https://issues.apache.org/jira/browse/WICKET-6877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17325035#comment-17325035 ] 

ASF subversion and git services commented on WICKET-6877:
---------------------------------------------------------

Commit e11bc07c1b147c55766638ecaba899956505857b in wicket's branch refs/heads/master from Martin Tzvetanov Grigorov
[ https://gitbox.apache.org/repos/asf?p=wicket.git;h=e11bc07 ]

WICKET-6877 Removing component's MetaData during detach phase from within a Behavior causes issue

Reset the iteration index and upper bound while detaching Component's behaviors if the Behavior modifies the Component's data anyhow


> Removing component's MetaData during detach phase from within a Behavior causes issue
> -------------------------------------------------------------------------------------
>
>                 Key: WICKET-6877
>                 URL: https://issues.apache.org/jira/browse/WICKET-6877
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 9.3.0, 8.12.0
>            Reporter: Daniel Radünz
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Minor
>         Attachments: quickstart.zip
>
>
> When removing a component's MetaData entry from within a Behavior's {{detach(Component component)}} method, Wicket can run into issues due to a loop index being out of sync with the array it is iterating over.
> The attached quickstart shows the problem in the log when the HomePage is opened.
> Explanation:
> The included VisibilityBehavior class adds a MetaData entry to the component it is attached to. Upon detaching the Behavior this MetaData entry is set to null again. Setting a MetaData entry to null removes it from the component's data array, moving all elements following it further up in the array.
> State captured in {{org.apache.wicket.Behaviors.detach(Component)}}:
> Right before detaching the Behavior:
>  Loop index "i" = 2
>  Content of the component's "data" array:
>  - [0] the component's Model
>  - [1] the MetaDataEntry belonging to the described Behavior
>  - [2] the Behavior itself
>  - [3] an AttributeModifier with a StringResourceModel
> Start of next iteration after the Behavior was detached
>  Loop index "i" = 3
>  Content of the component's "data" array:
>  - [0] the component's Model
>  - [1] the Behavior itself
>  - [2] an AttributeModifier with a StringResourceModel
> Result:
>  The AttributeModifier is skipped and doesn't get detached, resulting in the NotDetachedModelChecker reporting a not detached model in the AttributeModifier, when the HomePage gets opened.
> This might be fixable with the suggested separation of Models, Behaviors and MetaData from WICKET-6774. Alternatively Wicket could maybe raise an exception or log a warning if the size of the data field changed during detaching.
> The problem was first discovered in 8.10.0 and reproduced with 9.3.0 in the quickstart.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)