scalatestin-memory-databasemongodb-scala

Future[WriteResult] is Failing with ArrayOutOfBounds exception while using scalatest-embedMongo with reactivemongo scala driver version 0.11.5


I am using scalatest-embedMongo as In-memory version of mongoDB for a Scala application. I have currently upgraded my reactivemongo driver from version 0.10.x to version 0.11.5. The scalatest-embedMongo was working fine with the previous version of reactive mongo scala driver but, with the upgraded version of reactive mongo driver, The WriteResult Future is always returning with a Failure containing ArrayIndexOutOfBounds sourcing from the reactiveMongo driver API. I am puzzled with this new exception.

Here goes the entire stack trace:

java.lang.ArrayIndexOutOfBoundsException: 123
at org.jboss.netty.buffer.LittleEndianHeapChannelBuffer.getInt(LittleEndianHeapChannelBuffer.java:69)
at reactivemongo.api.SerializationPack$class.readAndDeserialize(serializationpack.scala:31)
at reactivemongo.api.BSONSerializationPack$.readAndDeserialize(serializationpack.scala:41)
at reactivemongo.api.collections.GenericCollection$$anonfun$update$1$$anonfun$apply$14.apply(genericcollection.scala:314)
at reactivemongo.api.collections.GenericCollection$$anonfun$update$1$$anonfun$apply$14.apply(genericcollection.scala:313)
at scala.util.Success$$anonfun$map$1.apply(Try.scala:206)
at scala.util.Try$.apply(Try.scala:161)
at scala.util.Success.map(Try.scala:206)
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Thanks in advance!!


Solution

  • First, Scalatest embed mongo is not design to embed mongo in production (in fact it is not tested for that) but if it work for you i'm ok.

    Second, If I remember, the version of mongo db used is important related with reactivemongo version. What MongoDb version do you set when you start a EmbedMongo instance ? By default, is is 2.4.8 that was set (I do invest time to update code) and it is not supported by the driver.