So, I want to update a session variable if this scala function returns true. I set it to always return true to debug this
part of the code. However, when I run and I print out the session variables at the end of the run the session variable "testNewSeg" is
never updated even though i know that it reaches the code inside the 'if' block. If anyone knows the solution to this problem
please let me know. Thanks!
.exec{session =>
if (newSegmentTest(session,"activity_server_id","isNewSeg"))
{exec(session => session
.set("testNewSeg","true")
)}
session
}
Warning
Session
instances are immutable!
Why is that so? Because Sessions are messages that are dealt with in a multi-threaded concurrent way, so immutability is the best way to deal with state without relying on synchronization and blocking.
A very common pitfall is to forget that set
and setAll
actually return new instances.
When I remove the last session I get a compile errors:
.exec{session => if(newSegmentTest(session,"activity_server_id","isNewSeg"))
Hey Barry,