Simulation stops abruptly when it encounters doIfOrElse

I have a scenario where the next request to be sent is based on a session attribute value that I extract from my current response.

To achieve this, I’m using:

.exec(http("Request 1") .post("/address/addressservice/getAddress") .check(jsonPath("$..addressId").find.optional.saveAs("homeAddressID") )

If homeAddressID exists, I want to send this ID in request body of my next request. If not, I wouldn’t send it. This is how I’m implementing:

`
doIfOrElse(session => session.contains(“homeAddressID”)){

println(“Home address id found”)
exec(http(“request_29”)
.options("/address/addressservice/saveAddress")
.headers(headers.headers_4)
.resources(http(“request_30”)
.post("/address/addressservice/saveAddress")
.headers(headers.headers_30)
.body(ElFileBody(“SaveAddressWAddressIDBody.txt”)).asJSON //This would have home address ID.
}

{
println(“Home address id is NOT found”)
exec(http(“request_29”)
.options("/address/addressservice/saveAddress")
.headers(headers.headers_4)
.resources(http(“request_30”)
.post("/address/addressservice/saveAddress")
.headers(headers.headers_30)
.body(ElFileBody(“SaveAddressWOAddressIDBody.txt”)).asJSON //This will NOT have home address ID.
}

//After this, there are 5 more requests
`

However when this is run, simulation only executes until doIfOrElse. Requests inside the loop and requests after the loop are not executed.
Also, I have inserted print statements to know which block of the loop was called, but both of those statements were printed in console at the beginning of the test:

Home address id found Home address id is NOT found 12:02:43.774 [INFO ] i.g.h.a.HttpEngine - Start warm up 12:02:44.757 [INFO ] i.g.h.a.HttpEngine - Warm up done Simulation OKRProfileEdit started...

Can someone please explain why would this be happening?

gatling-maven-plugin - 2.2.4
gatling-highcharts-maven-archetype - 2.3.1

scala - 2.12.3
gatling and gatling-charts-highcharts - 2.3.0
scala-maven-plugin - 3.2.2

apache-maven - 3.5.3

Got it working by correcting the obvious mistake:

It should be:

.doIfOrElse(){}{}

Instead of:

doIfOrElse(){}{}