Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented local integrity implications of com.hazelcast.web.WebFilter's deferred-write parameter #45

Closed
mdogan opened this issue Feb 16, 2017 · 3 comments
Assignees

Comments

@mdogan
Copy link

mdogan commented Feb 16, 2017

From @BGehrels on August 14, 2014 18:39

Due to the LocalCache not being enabled when not setting deferred-write=true, subsequent calls to session.getAttribute("myKey") will neither return the same instance, nor will changes to the returned object be visible to subsequent calls.

session.setAttribute("myKey", new ArrayList()); // Will serialize the ArrayList
List list1 = session.getAttribute("myKey"); // Will deserialize the original List
list1.add("myValue"); // Will not be serialized

List list2 session.getAttribute("myKey"); // Will deserialize the original List again
System.out.println(list1 == list2); // false
System.out.println(list1.getSize()) // 1
System.out.println(list2.getSize()) // 0

After reading the Servlet Spec, I'm not sure if this behaviour is compliant. The spec is not very verbose regarding this topic. But: Since the behaviour differs when switching deferred-write parameter on and off, it should at least be clearly documented (with a big red warning sign).

Took me quite some time digging through Spring Web Flows source code.

Copied from original issue: hazelcast/hazelcast#3269

@mdogan
Copy link
Author

mdogan commented Feb 16, 2017

From @BGehrels on August 15, 2014 12:26

I you want to provide a more transparent solution, you could think about returning java.lang.reflect.Proxy instances of the original session attribute values class, when deferred-write=false.

Whenever a Method of the Proxy instance is called, it would call

currentState = session.getAttribute(myKey)

to get the current object state, delegate to the object returned thereby

currentState.doSomething(args)

and then store the possibly changed state again

session.setAttribute(myKey, currentState)

@mdogan
Copy link
Author

mdogan commented Feb 16, 2017

From @mesutcelik on August 21, 2014 14:54

Thanks @BGehrels for the contribution. I have updated the doc.

Currently we are in a feature freeze phase so your request about java.lang.reflect.Proxy has been added to the backlog and will be considered in later releases.

@emre-aydin
Copy link
Contributor

Closing the issue as documentation is updated and the request about Proxy objects should not be implemented as it will hide the inherent network roundtrip from the application developer which will cause slow application performance. Application developers need to be aware that to store data in a session, you need to put the data you have modified back into the session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants