Hi!
I've the following problem: when I upgrade my application from ReactiveMongo 0.12.0 to 0.12.1 or 0.12.2 I get the following exception when serving files from GridFS:
java.lang.IllegalStateException: Promise already completed.
at scala.concurrent.Promise$class.complete(Promise.scala:55)
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:157)
I read the files this way:
def find(fileId: UUID): Future[Option[FileData]] = {
gridFS.find[JsObject, JSONReadFile](Json.obj("_id" -> fileId))
.headOption.map(_.map(r => FileData(FileMetadata(r.id.as[UUID], r.filename.get, r.contentType, r.uploadDate.map(new DateTime(_))), gridFS.enumerate(r))))
And I convert the Enumerator to Stream in order to stream it to the client in HTTP response:
val fileData = Source.fromPublisher(Streams.enumeratorToPublisher(f.content)).map(ByteString(_))
And this conversion leads to the problem. If I replace this conversion to the following, then the problem does not occur:
val content = f.content.run(Iteratee.consume[Array[Byte]]())
val fileData = Source.fromFuture(content).map(ByteString(_))
I guess this is a kind of hack, so it would be fine to solve it with standard streaming. Or am I doing something wrong?
Thanks,
Akos