Skip to content

NullPointerException in DefaultEventBus #156

@angeloh

Description

@angeloh

I have a handler which accepts client's connection and broadcasts his connected status to another eventbus address for its subscribers. This is how I test this handler.

It seems this error was created in the convertHandler. However, I didn't use sendWithTimeout or replyWithTimeout in my code.

  @Test
  def testSockJSVerticleConnect() {
    import org.vertx.scala.core.FunctionConverters._
    container.deployVerticle("scala:verticles.SockJSVerticle", Json.obj(), 1, {
      case Success(deploymentId) => {

          lazy val hdl = (msg: Message[JsonObject]) => {
              assertEquals("connected", msg.body.getString("status"))
              testComplete()
          }
          vertx.eventBus.registerHandler("eb.pres.memberid1", hdl) // test if memberid1 connected

          vertx.createHttpClient.setHost("localhost").setPort(8081).connectWebsocket("/ws/websocket",
             (w: WebSocket) => {
            val msg = Json.obj("body" -> Json.obj("action" -> "connect", "memberId" -> "memberid1"),
             "type" -> "send", "address" -> "eb.conn")
            w.writeTextFrame(msg.encode()) // memberid1 connects
          })

      }
      case Failure(ex) => fail()
    }: Try[String] => Unit)
  }

But I always see this exception showing up even the test case runs fine.

    SEVERE: Scala verticle threw exception
    java.lang.NullPointerException
        at org.vertx.java.core.eventbus.impl.DefaultEventBus$6.handle(DefaultEventBus.java:755)
        at org.vertx.java.core.eventbus.impl.DefaultEventBus$6.handle(DefaultEventBus.java:745)
        at org.vertx.java.core.eventbus.impl.DefaultEventBus$11.run(DefaultEventBus.java:943)
        at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:175)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:370)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at java.lang.Thread.run(Thread.java:724)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions