[
https://issues.apache.org/jira/browse/WICKET-6334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899495#comment-15899495
]
Sven Meier commented on WICKET-6334:
------------------------------------
I did not dig very deep into this issue yet, but the attached simple example
has a forbidden usage of models:
{code}
private IModel<String> model;
public synchronized IModel<String> getLDM() {
if (model == null) {
model = new LoadableDetachableModel<String>() {
@Override
protected String load() {
return "Hello World!";
}
};
}
return model;
}
{code}
- a Session is not single-threaded, a LoadableDetachableModel is not
thread-safe, thus this usage is a recipe for desaster
- note the anonymous inner class holds a reference to the containing Session,
this is forbidden too
- using a model in a session is dubious at the first place: each component
calling #getLDM() will get its own copy of the model serialized along with
itself, so why pretend it will be shared? It won't be,
I'd suggest that first we get a valid use case from the reporting user, then we
can discuss which measures we want to take or whether we have a problem at all.
> WicketObjects#sizeof() should detach Sessions
> ---------------------------------------------
>
> Key: WICKET-6334
> URL: https://issues.apache.org/jira/browse/WICKET-6334
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 7.6.0
> Reporter: Martin Grigorov
> Assignee: Martin Grigorov
> Priority: Minor
>
> Report at users@ : http://markmail.org/message/mq5zs2veaj4q4psg
> Wicket should detach the Session before calculating its size as it does for
> Component and IDetachable.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)