Uploaded image for project: 'Scala'
  1. Scala
  2. SCALA-323

Macros break with extra array field

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.0
    • Component/s: bson
    • Labels:
      None

      Description

      I'm using the 2.2.0 driver (built from master) and Scala 2.12.

      This commit forgot to handle extra arrays. When I try to load a case class from an underlying document containing an extra array field, I get this error:

      java.util.NoSuchElementException: head of empty list
      	at scala.collection.immutable.Nil$.head(List.scala:428)
      	at scala.collection.immutable.Nil$.head(List.scala:425)
      	at org.mongodb.scala.bson.codecs.macrocodecs.MacroCodec.readArray(MacroCodec.scala:187)
      	at org.mongodb.scala.bson.codecs.macrocodecs.MacroCodec.readArray$(MacroCodec.scala:182)
      	at com.highrisegame.util.Mongo$$anon$4$PostMacroCodec$3.readArray(Mongo.scala:37)
      	at org.mongodb.scala.bson.codecs.macrocodecs.MacroCodec.readValue(MacroCodec.scala:174)
      	at org.mongodb.scala.bson.codecs.macrocodecs.MacroCodec.readValue$(MacroCodec.scala:169)
      	at com.highrisegame.util.Mongo$$anon$4$PostMacroCodec$3.readValue(Mongo.scala:37)
      	at org.mongodb.scala.bson.codecs.macrocodecs.MacroCodec.decode(MacroCodec.scala:104)
      	at org.mongodb.scala.bson.codecs.macrocodecs.MacroCodec.decode$(MacroCodec.scala:96)
      	at com.highrisegame.util.Mongo$$anon$4$PostMacroCodec$3.decode(Mongo.scala:37)
      	at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
      	at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:53)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
      	at org.bson.codecs.configuration.LazyCodec.decode(LazyCodec.java:47)
      	at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101)
      	at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:56)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
      	at com.mongodb.connection.ReplyMessage.<init>(ReplyMessage.java:57)
      	at com.mongodb.connection.CommandProtocol.getResponseDocument(CommandProtocol.java:139)
      	at com.mongodb.connection.CommandProtocol.access$000(CommandProtocol.java:51)
      	at com.mongodb.connection.CommandProtocol$CommandResultCallback.callCallback(CommandProtocol.java:271)
      	at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:48)
      	at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:23)
      	at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:470)
      	at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:464)
      	at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:119)
      	at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:115)
      	at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
      	at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:378)
      	at com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:66)
      	at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:420)
      	at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:389)
      	at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:562)
      	at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:517)
      	at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:584)
      	at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:568)
      	at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:447)
      	at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
      	at com.mongodb.connection.netty.NettyStream.readAsync(NettyStream.java:234)
      	at com.mongodb.connection.InternalStreamConnection.readAsync(InternalStreamConnection.java:444)
      	at com.mongodb.connection.InternalStreamConnection.access$2000(InternalStreamConnection.java:66)
      	at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onResult(InternalStreamConnection.java:541)
      	at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onResult(InternalStreamConnection.java:517)
      	at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
      	at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:447)
      	at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
      	at com.mongodb.connection.netty.NettyStream.readAsync(NettyStream.java:234)
      	at com.mongodb.connection.netty.NettyStream.handleReadResponse(NettyStream.java:264)
      	at com.mongodb.connection.netty.NettyStream.access$500(NettyStream.java:64)
      	at com.mongodb.connection.netty.NettyStream$InboundBufferHandler.channelRead0(NettyStream.java:315)
      	at com.mongodb.connection.netty.NettyStream$InboundBufferHandler.channelRead0(NettyStream.java:312)
      	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
      	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1273)
      	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1084)
      	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
      	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
      	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
      	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
      	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
      	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
      	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
      	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
      	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
      	at java.lang.Thread.run(Thread.java:745)
      
      

        Attachments

          Activity

            People

            Assignee:
            ross.lawley Ross Lawley
            Reporter:
            fedenusy13 Federico Nusymowicz
            Participants:
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: