Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redisClient.getBinary throws Null Pointer Exception when the result is null #149

Closed
UkonnRa opened this issue Apr 17, 2019 · 4 comments
Closed
Labels
Milestone

Comments

@UkonnRa
Copy link

UkonnRa commented Apr 17, 2019

Version

  • vert.x core: 3.7.0
  • vert.x redis client: 3.7.0

Context

I encountered an exception which looks suspicious while using Redis as Vert.x Cluster Session.

This error is only encountered at 3.7.0, 3.6.3 works fine

Do you have a reproducer?

The redisClient.getBinary function throws this error, when the result is null

@Override
  public void put(Session session, Handler<AsyncResult<Void>> resultHandler) {
    redisClient.getBinary(
        session.id(),
        res1 -> {
          if (res1.succeeded()) {
            if (res1.result() != null) {
              Buffer buffer = res1.result();
              SharedDataSessionImpl oldSession = new SharedDataSessionImpl(new PRNG(vertx));
              oldSession.readFromBuffer(0, buffer);
              SharedDataSessionImpl newSession = (SharedDataSessionImpl) session;
              if (oldSession.version() != newSession.version()) {
                resultHandler.handle(Future.failedFuture("Version mismatch"));
                return;
              }
              newSession.incrementVersion();
              writeSession(session, resultHandler);
            } else {
              SharedDataSessionImpl newSession = (SharedDataSessionImpl) session;
              newSession.incrementVersion();
              writeSession(session, resultHandler);
            }
          } else {
            resultHandler.handle(Future.failedFuture(res1.cause()));
          }
        });
  }

Extra

Error log:

[2019-04-17 21:25:33,625][vert.x-eventloop-thread-0][ERROR][io.vertx.redis.client.impl.RedisClient:87] Unhandled Error
java.lang.NullPointerException: null
        at io.vertx.redis.impl.RedisClientImpl.lambda$sendBuffer$7(RedisClientImpl.java:223) ~[vertx-redis-client-3.7.0.jar:3.7.0]
        at io.vertx.redis.client.impl.RedisClient.handle(RedisClient.java:341) ~[vertx-redis-client-3.7.0.jar:3.7.0]
        at io.vertx.redis.client.impl.RESPParser.handleResponse(RESPParser.java:228) ~[vertx-redis-client-3.7.0.jar:3.7.0]
        at io.vertx.redis.client.impl.RESPParser.handleResponse(RESPParser.java:186) ~[vertx-redis-client-3.7.0.jar:3.7.0]
        at io.vertx.redis.client.impl.RESPParser.handle(RESPParser.java:121) ~[vertx-redis-client-3.7.0.jar:3.7.0]
        at io.vertx.redis.client.impl.RESPParser.handle(RESPParser.java:25) ~[vertx-redis-client-3.7.0.jar:3.7.0]
        at io.vertx.core.net.impl.NetSocketImpl$DataMessageHandler.handle(NetSocketImpl.java:393) ~[vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:230) ~[vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:120) ~[vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:371) ~[vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.net.impl.ConnectionBase.handleRead(ConnectionBase.java:390) ~[vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320) [vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43) [vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:188) [vertx-core-3.7.0.jar:3.7.0]
        at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:174) [vertx-core-3.7.0.jar:3.7.0]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.30.Final.jar:4.1.30.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
@pmlopes
Copy link
Member

pmlopes commented Apr 17, 2019

this issue should be already fixed on master.

@UkonnRa
Copy link
Author

UkonnRa commented Apr 17, 2019

@pmlopes On master? Have you pushed the patch to maven central? it does still not work even I update the maven repo's index...

@pmlopes
Copy link
Member

pmlopes commented Apr 18, 2019

no, it's not on maven central to test you need to build from source.

@pmlopes pmlopes added this to the 3.7.1 milestone Apr 29, 2019
@pmlopes pmlopes added the bug label Apr 29, 2019
@pmlopes
Copy link
Member

pmlopes commented Apr 29, 2019

Fixed on master and 3.7.1

@pmlopes pmlopes closed this as completed Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants