Skip to content

Commit

Permalink
[TOREE-548] Call shutdown to close ZQM Context in ZeroMQSocketRunnabl…
Browse files Browse the repository at this point in the history
…eSpec (#214)
  • Loading branch information
pan3793 authored Aug 10, 2023
1 parent 86f6561 commit 9e408a3
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.scalatest.time.{Milliseconds, Seconds, Span}
import org.scalatest.{BeforeAndAfter, FunSpec, Matchers}
import org.zeromq.{SocketType, ZMQ}
import org.zeromq.ZMQ.{Context, Socket}
import zmq.Ctx

import scala.util.Try

Expand Down Expand Up @@ -61,7 +62,14 @@ class ZeroMQSocketRunnableSpec extends FunSpec with Matchers
}

after {
Try(zmqContext.close())
Try {
val ctxFiled = classOf[ZMQ.Context].getClass.getDeclaredField("ctx")
ctxFiled.setAccessible(true)
val ctx = ctxFiled.get(zmqContext).asInstanceOf[Ctx]
val shutdownMethod = classOf[Ctx].getDeclaredMethod("shutdown")
shutdownMethod.setAccessible(true)
shutdownMethod.invoke(ctx)
}
}

describe("ZeroMQSocketRunnable") {
Expand Down

0 comments on commit 9e408a3

Please sign in to comment.