gatling/scala question

Sorry for the newbie question… I’ve searched the documentation and user group before posting…

I have custom code in an exec block :

.exec((s : Session) => {
if (condition)




The http post request is not sent… i’ve turned on debugging and there is no mention there…

Another thing…
I’ve tried using s.setAttribute(“value”, …) in the custom code and later in an exec use EL “${value}” and it didn’t work either…

Any suggestions?

Thanks in advance,

Hi again,

First question:
Nope, won’t work… 328.png

What you’re doing is defining a custom action where you create a new request builder. So? This request builder is never built and the resulting request executed.

What you have to do is use the doIf directive:

Second question:

Beware that, just like scenario elements builders, sessions are immutable.

Meaning that session.setAttribute(“foo”, “bar”) will return a new Session instance that has to be returned. That’s why when executing a custom action, you’re expected to return a Session instance.

.exec{(session: Session) =>
session.setAttribute(“foo”, “bar”) // creates a new Session instance, and return it (in Scala, the result of the last operation in the block is returned)

Hope that helps,


2012/10/11 erik ashepa <>