jklingsporn / vertx-jooq

A jOOQ-CodeGenerator to create vertx-ified DAOs and POJOs.
MIT License
385 stars 53 forks source link

dao.insertReturningPrimary fails with java.util.NoSuchElementException #149

Closed marioc-bitheads closed 4 years ago

marioc-bitheads commented 4 years ago

Using MySQL w/ ClassicReactiveVertxGenerator

using

dao.insert(body.getPojo()) succeed

but dao.insertReturningPrimary(body.getPojo())

fails and returns : java.util.NoSuchElementException at java.base/java.util.ArrayList$Itr.next(ArrayList.java:999) at io.vertx.sqlclient.impl.RowSetImpl$1.next(RowSetImpl.java:74) at io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicQueryExecutor.lambda$insertReturning$2(ReactiveClassicQueryExecutor.java:39) at io.vertx.core.Future.lambda$map$4(Future.java:405) at io.vertx.core.impl.FutureImpl.dispatch(FutureImpl.java:105) at io.vertx.core.impl.FutureImpl.tryComplete(FutureImpl.java:150) at io.vertx.core.impl.FutureImpl.complete(FutureImpl.java:111) at io.vertx.core.impl.FutureImpl.handle(FutureImpl.java:176) at io.vertx.core.impl.FutureImpl.handle(FutureImpl.java:21) at io.vertx.sqlclient.impl.SqlResultHandler.complete(SqlResultHandler.java:97) at io.vertx.sqlclient.impl.SqlResultHandler.handle(SqlResultHandler.java:86) at io.vertx.sqlclient.impl.SqlResultHandler.handle(SqlResultHandler.java:33) at io.vertx.sqlclient.impl.PoolBase$1.lambda$onSuccess$0(PoolBase.java:102) at io.vertx.sqlclient.impl.SocketConnectionBase.handleMessage(SocketConnectionBase.java:210) at io.vertx.sqlclient.impl.SocketConnectionBase.lambda$init$0(SocketConnectionBase.java:81) at io.vertx.core.net.impl.NetSocketImpl.lambda$new$2(NetSocketImpl.java:101) at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:237) at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:127) at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:357) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369) at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43) at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:232) at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:173) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.vertx.mysqlclient.impl.codec.MySQLEncoder.lambda$write$0(MySQLEncoder.java:58) at io.vertx.mysqlclient.impl.codec.QueryCommandBaseCodec.handleAllResultsetDecodingCompleted(QueryCommandBaseCodec.java:178) at io.vertx.mysqlclient.impl.codec.QueryCommandBaseCodec.handleSingleResultsetDecodingCompleted(QueryCommandBaseCodec.java:141) at io.vertx.mysqlclient.impl.codec.ExtendedQueryCommandBaseCodec.handleInitPacket(ExtendedQueryCommandBaseCodec.java:26) at io.vertx.mysqlclient.impl.codec.QueryCommandBaseCodec.decodePayload(QueryCommandBaseCodec.java:58) at io.vertx.mysqlclient.impl.codec.ExtendedQueryCommandCodec.decodePayload(ExtendedQueryCommandCodec.java:100) at io.vertx.mysqlclient.impl.codec.MySQLDecoder.decodePayload(MySQLDecoder.java:62) at io.vertx.mysqlclient.impl.codec.MySQLDecoder.decode(MySQLDecoder.java:51) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:498) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:437) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

jklingsporn commented 4 years ago

This is a bug indeed. I've managed to reproduce it and working on a fix now.

jklingsporn commented 4 years ago

This has been fixed in https://github.com/jklingsporn/vertx-jooq/tree/%23149. Apparently nobody used the reactive mysql client before 😄 Unfortunately there are issues with the transaction-handling though. The tests use the exact same methods as the postgres-client but for mysql, they fail. So I am more or less certain that transactions do not work properly with the reactive-mysql-client.

marioc-bitheads commented 4 years ago

Thanks, Since I'm building something brand new, should I look into switching to Postgres instead, (I also had problems with json data type in MySQL)?

jklingsporn commented 4 years ago

It is a matter of taste, but I favor postgres over mysql. In terms of vertx-jooq I'd strongly advise for the postgres driver.

marioc-bitheads commented 4 years ago

Awesome, thanks for your advise.