Details
-
Bug
-
Resolution: Duplicate
-
Minor - P4
-
None
-
None
-
None
Description
The following test fails with AssertionError: expected:<class [B> but was:<class org.bson.types.Binary>
@Test
|
public void testByteArray() {
|
MongoClient mongo = new MongoClient();
|
MongoDatabase db = mongo.getDatabase("mydb");
|
MongoCollection<Document> collection = db.getCollection("test");
|
try {
|
collection.insertOne(new Document("image", "MongoDB".getBytes()));
|
assertEquals(byte[].class, collection.find().first().get("image").getClass());
|
} finally {
|
collection.drop();
|
mongo.close();
|
}
|
}
|
It appears, byte array is encoded properly with ByteArrayCodec, but is decoded to BsonBinary, by BinaryCodec.
Probably BinaryCodec should be obsoleted, and removed from ValueCodecProvider.addCodecs, and BsonTypeClassMap.addDefault() should have map.put(BsonType.BINARY, byte[].class) instead of map.put(BsonType.BINARY, Binary.class)
Attachments
Issue Links
- duplicates
-
JAVA-1292 Support binary decoding transformations
-
- Closed
-