Skip to content

Commit

Permalink
fix: Don't crash with CCE when fetching a Java Map with Gatling EL, c…
Browse files Browse the repository at this point in the history
…lose #4556

Modification:

javaMap.asScala is a `mutable.Map`.
  • Loading branch information
slandelle committed Apr 25, 2024
1 parent cea87d8 commit 65b40d7
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -285,14 +285,14 @@ object TypeCaster extends LowPriorityTypeCaster {
override def cast(key: String, value: Any): Map[String, Any] =
value match {
case scalaMap: Map[_, _] => scalaMap.asInstanceOf[Map[String, Any]]
case javaMap: ju.Map[_, _] => javaMap.asScala.asInstanceOf[Map[String, Any]]
case javaMap: ju.Map[_, _] => javaMap.asScala.toMap.asInstanceOf[Map[String, Any]]
case _ => throw new ClassCastException(cceMessage(key, value, classOf[Map[_, _]]))
}

override def validate(key: String, value: Any): Validation[Map[String, Any]] =
value match {
case scalaMap: Map[_, _] => scalaMap.asInstanceOf[Map[String, Any]].success
case javaMap: ju.Map[_, _] => javaMap.asScala.asInstanceOf[Map[String, Any]].success
case javaMap: ju.Map[_, _] => javaMap.asScala.toMap.asInstanceOf[Map[String, Any]].success
case _ => cceMessage(key, value, classOf[Map[_, _]]).failure
}
}
Expand Down

0 comments on commit 65b40d7

Please sign in to comment.