Skip to content

Commit 3ab39ea

Browse files
committed
GridFS Upload Problem with 4.2 driver found
1 parent 8b11e9b commit 3ab39ea

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
## Versions
55

6+
### 2.2.3
7+
* rollback to mongo-scala-driver [4.1.2](https://mongodb.github.io/mongo-java-driver/4.2/driver-scala/) because of critical bug in GridFS Upload
8+
69
### 2.2.2
710
* mongo-scala-driver [4.2.3](https://mongodb.github.io/mongo-java-driver/4.2/driver-scala/)
811

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ libraryDependencies += "joda-time" % "joda-time" % "2.10.10" % Test
5555

5656
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.11" % Test
5757

58-
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "4.2.3"
58+
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "4.1.2"
5959

6060
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.8.4" % Provided
6161

src/test/scala/com/sfxcode/nosql/mongo/gridfs/GridFSDatabaseSpec.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import org.bson.types.ObjectId
88
import org.specs2.mutable.Specification
99
import org.specs2.specification.BeforeAll
1010

11+
import scala.io.Source
12+
1113
class GridFSDatabaseSpec extends Specification with GridfsDatabaseFunctions with BeforeAll {
1214

1315
"GridFSDatabase" should {
@@ -20,12 +22,12 @@ class GridFSDatabaseSpec extends Specification with GridfsDatabaseFunctions with
2022

2123
}
2224

23-
24-
2525
"insert file and in" in {
2626
val fileName = "scala-logo.png"
2727

28-
val oid: ObjectId = insertImage(ImageDAOSourcePath + fileName, ImageMetadata("template1", group = "templates"))
28+
val filePath = ImageDAOSourcePath + fileName
29+
val oid: ObjectId = insertImage(filePath, ImageMetadata("template1", group = "templates"))
30+
val uploadBytes = File(filePath).bytes.toList
2931

3032
val file = findImage(oid)
3133
file.getFilename must be equalTo fileName
@@ -39,7 +41,14 @@ class GridFSDatabaseSpec extends Specification with GridfsDatabaseFunctions with
3941

4042
result must not be equalTo(-1)
4143

42-
File(downloadPath).exists must beTrue
44+
val downloadedFile = File(downloadPath)
45+
downloadedFile.exists must beTrue
46+
47+
val downloadBytes = File(downloadPath).bytes.toList
48+
49+
downloadBytes.size must be equalTo uploadBytes.size
50+
51+
downloadBytes must be equalTo uploadBytes
4352

4453
}
4554

0 commit comments

Comments
 (0)