kuujo / vertigo

Flow-based programming for the Vert.x application platform.
Apache License 2.0
155 stars 24 forks source link

NPE while removing connection #10

Closed andredasilvapinto closed 11 years ago

andredasilvapinto commented 11 years ago

The timeout handler in DefaultOutputCollector.doListen() can repetitively try to remove an already "removed" connection.

The relevant code:

          if (channel.containsConnection(address)) {
            channel.removeConnection(channel.getConnection(address));
          }

The problem is that while containsConnection is a simple containsKey call to the map, channel.getConnection performns returns null instead of the map value for connections of type PseudoConnection. This sends null as the argument of removeConnection which provokes a NPE similar to this one:

Exception in Java verticle
java.lang.NullPointerException
        at net.kuujo.vertigo.output.DefaultChannel.removeConnection(DefaultChannel.java:93)
        at net.kuujo.vertigo.output.DefaultOutputCollector$3.handle(DefaultOutputCollector.java:141)
        at net.kuujo.vertigo.output.DefaultOutputCollector$3.handle(DefaultOutputCollector.java:137)
        at org.vertx.java.core.impl.DefaultVertx$InternalTimerHandler.run(DefaultVertx.java:418)
        at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
        at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
        at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:123)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
        at java.lang.Thread.run(Thread.java:722)
andredasilvapinto commented 11 years ago

Thanks