Problem with session.set


I discovered a strange behavior when I set a boolean value in a session. With the following Simulation:

class TestSimulation extends Simulation {

val endSim = new Date().getTime() + (1 minute).toMillis;

val httpConf = http

val scn = scenario(“Test”)
.exec(session => {
session.set(“continue”, true);
.asLongAs(session => (session(“continue”).asOption[Boolean].getOrElse(false) && new Date().getTime() < endSim).success) {
exec(session => {
println(“Set continue to false”)
session.set(“continue”, false)
.exec(session => {


I have the following output:
Set error to false
Set error to false

But I never reach the “test” println

If I change session.set(“error”, false) by session.set(“error”, true) then it works. I also tried with an Int instead of a Boolean and I get the same behavior when the value becomes 0

I am using last commit from gatling master


Woops, forgot to document that:

Loops now have an exitASAP parameter (defaulting to true) that causes the exit condition to be evaluated on every element inside the loop:
asLongAs(condition = session => session(“continue”).asOption[Boolean].getOrElse(false) && new Date().getTime() < endSim, exitASAP = false)

Also note that:

  • there’s an implicit that converts values into Validations, so in most cases, you don’t have to add .success
  • since you’re using latest master, you can use the new maxDuration built-in that exactly do what you’re doing with your endSim test:



Thank for the reply and tips :slight_smile: