Checking if value is or is not null - Gatling 3.3

Hi all,
I’m having some troubles with my code. I need to calculate whole processing time - need to wait until the system will response with correct values. “Correct” in this case means that the “currentDate” value is not null.

I’ve used some solutions found on the Internet, but still having such error: “10:08:15.949 [ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - ‘hook-2’ crashed with ‘j.l.ClassCastException: Value is null’, forwarding to the next one”. It is null and it should be for some time, so the system response is correct.

Could someone help me and tell what I’m doing wrong? Sorry for meaningless names, but it’s commercial code and I couldn’t use exact names.

val sendAnotherRequest=
exec(
http(“Another Request”)
.put(BaseUrls.SomethingDifferent)
.headers(BaseHeader.baseHeaders)
.header(“authorization”, “${Token}”)
.body(Templates.template).asJson
)

val saveDate =
exec(
http(“Save Value From DB”)
.get(BaseUrls.Something)
.headers(BaseHeader.baseHeaders)
.queryParam(“ID”, “${id}”)
.check(jsonPath(“$…Date”)
.saveAs(“currentDate”)
)
)

val requestFullyProcessed =
group(“Request Processed”) {
exec(Requests.sendAnotherRequest)
.exec(Requests.saveDate)
.asLongAsDuring(session => Option(session(“currentDate”)) == None, GlobalVariables.timeout) {
exec(Requests.saveDate)
}
}

What’s more - in the PS console I’m getting such values for requests described above:

Request Processed / Another Request (OK=119 KO=0 )
Request Processed / Save Value From DB (OK=119 KO=0 )

I assume that “saveDate” request should be executed many more times than the “anotherRequest” - it’s checked continuously, so the system should response many times with null and then with correct value. For other requests written this way, we’re getting e.g. 132 executions for the first one and 2697 for the second one, so even order of magnitude is different.

Thanks in advance for any help!

Best regards,
Stefania

Hi all,

I’ve finally found a solution and big workaround described here: http://performance-related.blogspot.com/2019/01/gatling-load-test-tricks-and-debug.html .
If there’s still a chance that someone could explain me why the Option cast doesn’t work correctly, I would appreciate the explanation.

Best regards,
Stefania