From 4176fb3fbac69cb56baa62c6fe0564997ffebf6c Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Wed, 22 Oct 2025 11:05:23 +0100 Subject: [PATCH] Improve GridFSObservableSpec#cleanup when unsubscribing Slow down the writing of chunks. Sleep for longer between retries. JAVA-5998 --- .../mongodb/scala/gridfs/GridFSObservableSpec.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/driver-scala/src/integrationTest/scala/org/mongodb/scala/gridfs/GridFSObservableSpec.scala b/driver-scala/src/integrationTest/scala/org/mongodb/scala/gridfs/GridFSObservableSpec.scala index e6ca96183e6..e5c0420f6f1 100644 --- a/driver-scala/src/integrationTest/scala/org/mongodb/scala/gridfs/GridFSObservableSpec.scala +++ b/driver-scala/src/integrationTest/scala/org/mongodb/scala/gridfs/GridFSObservableSpec.scala @@ -16,6 +16,8 @@ package org.mongodb.scala.gridfs +import com.mongodb.client.gridfs.model.GridFSUploadOptions + import java.io.ByteArrayOutputStream import java.nio.ByteBuffer import java.nio.channels.Channels @@ -345,7 +347,11 @@ class GridFSObservableSpec extends RequiresMongoDBISpec with FuturesSpec with Be override def onComplete(): Unit = completed = true } gridFSBucket - .uploadFromObservable("myFile", Observable(List.fill(1024)(ByteBuffer.wrap(contentBytes)))) + .uploadFromObservable( + "myFile", + Observable(List.fill(1024)(ByteBuffer.wrap(contentBytes))), + new GridFSUploadOptions().chunkSizeBytes(1024) + ) .subscribe(observer) observer.subscription().request(1) @@ -368,7 +374,7 @@ class GridFSObservableSpec extends RequiresMongoDBISpec with FuturesSpec with Be } catch { case e: Exception => if (n > 1) { - Thread.sleep(250) + Thread.sleep(500) retry(n - 1)(fn) } else { throw e