Custom Feeder does not get populate at runtime

Hello Team,

Am trying to implement custom feeder which is based on response from scenario1. scenario 2 using the feeder which was populated by scenario1. Am getting compilation error as my feeder is empty at the init.

My intention is to ramp scn1 multiple times and populate feeder .andThen
ramp scn2 based on the feeder values.

var customFeeder: ArrayBuffer[Map[String, String]] = ArrayBuffer.empty

val scn1 = scenario(“Get value”)
.exce( do API call here add set token to the session)
.exec({ session =>
customFeeder.addOne(Map(“token” → session(“token”).as[String])

val scn2 = scenario(“use value”)
.exec{session =>
print(">>>>> " + session(“token”).as[String])

And am getting below error

15:38:02.252 [ERROR] i.g.a.Gatling$ - Run crashed
java.lang.IllegalArgumentException: requirement failed: Feeder must not be empty
at scala.Predef$.require(Predef.scala:338)
at io.gatling.core.feeder.InMemoryFeederSource.(FeederSource.scala:38)
at io.gatling.core.feeder.FeederSupport.array2FeederBuilder(FeederSupport.scala:32)
at io.gatling.core.feeder.FeederSupport.array2FeederBuilder$(FeederSupport.scala:31)
at io.gatling.core.Predef$.array2FeederBuilder(Predef.scala:23)

… 11 common frames omitted
Wrapped by: java.lang.ExceptionInInitializerError: null

You have to enforce batching and make sure column headers are populated upfront.