[
https://issues.apache.org/jira/browse/WICKET-6334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899555#comment-15899555
]
Ihor Parashynets edited comment on WICKET-6334 at 3/7/17 2:54 PM:
------------------------------------------------------------------
Hello Mr.Meier
To answer your concerns:
{quote}
a Session is not single-threaded, a LoadableDetachableModel is not thread-safe,
thus this usage is a recipe for desaster
{quote}
yes, but it doesn't prevent of such usage. If the application relays that
session and the model itself provide proper handling of concurrency I'd it's
the usage problem rather that excuses for the framework. This was just
simplification usecase to get the idea.
{quote}
note the anonymous inner class holds a reference to the containing Session,
this is forbidden too
{quote}
you can replace it by the following code:
{code:java}
public class MySession extends WebSession {
private IModel<String> model = new MyLoadableDetachableModel();
...
}
{code}
{quote}
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
{quote}
take a use-case where session serialization doesn't matter (no bookmarkable
pages are used, sticky session, etc)... and event if it would be - there might
be an implementation where LDM is properly "de-serialiazed" (session scope
level).
And I'm just curious why is it forbidden to have a model within Session if it's
properly handled?
The issue is not about how to use session and models within Wicket but rather
why this error appears in the log if model is being detached properly at the
end?
Thank you.
was (Author: ihorps):
Hello Mr.Meier
To answer your concerns:
{quote}
a Session is not single-threaded, a LoadableDetachableModel is not thread-safe,
thus this usage is a recipe for desaster
{quote}
yes, but it doesn't prevent of such usage. If the application relays that
session and the model itself provide proper handling of concurrency I'd it's
the usage problem rather that excuses for the framework. This was just
simplification usecase to get the idea.
{quote}
note the anonymous inner class holds a reference to the containing Session,
this is forbidden too
{quote}
you can replace it by the following code:
{code:java}
public class MySession extends WebSession {
private IModel<String> model = new LoadableDetachableModel<String>() {
@Override
protected String load() {
return "Hello World!";
}
}
...
}
{code}
{quote}
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
{quote}
take a use-case where session serialization doesn't matter (no bookmarkable
pages are used, sticky session, etc)... and event if it would be - there might
be an implementation where LDM is properly "de-serialiazed" (session scope
level).
And I'm just curious why is it forbidden to have a model within Session if it's
properly handled?
The issue is not about how to use session and models within Wicket but rather
why this error appears in the log if model is being detached properly at the
end?
Thank you.
> 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)