mongo java driver org.bson.BsonSerializationException

302 views
Skip to first unread message

bone he

unread,
May 23, 2017, 11:23:26 PM5/23/17
to mongodb-user
why mongodb will throw 
org.bson.BsonSerializationException: Found a BSON string that is not null-terminated.
at org.bson.io.ByteBufferBsonInput.readString(ByteBufferBsonInput.java:158)
at org.bson.io.ByteBufferBsonInput.readString(ByteBufferBsonInput.java:126)
at org.bson.BsonBinaryReader.doReadString(BsonBinaryReader.java:245)
at org.bson.AbstractBsonReader.readString(AbstractBsonReader.java:461)
at org.bson.codecs.StringCodec.decode(StringCodec.java:39)
at org.bson.codecs.StringCodec.decode(StringCodec.java:28)
at org.bson.codecs.DocumentCodec.readValue(DocumentCodec.java:212)
at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:141)
at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:45)
at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:53)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
at org.bson.codecs.configuration.LazyCodec.decode(LazyCodec.java:47)
at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101)
at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:56)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
at com.mongodb.connection.ReplyMessage.<init>(ReplyMessage.java:57)
at com.mongodb.connection.CommandProtocol.getResponseDocument(CommandProtocol.java:139)
at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:118)
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:168)
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:289)
at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:176)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:216)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:207)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:113)
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:516)
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:510)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:431)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:404)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:510)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:81)
at com.mongodb.Mongo.execute(Mongo.java:836)
at com.mongodb.Mongo$2.execute(Mongo.java:823)
at com.mongodb.OperationIterable.iterator(OperationIterable.java:47)
at com.mongodb.OperationIterable.forEach(OperationIterable.java:70)
at com.mongodb.FindIterableImpl.forEach(FindIterableImpl.java:166)
at com.mongodb.MappingIterable.forEach(MappingIterable.java:50)
at com.mongodb.MappingIterable.into(MappingIterable.java:60)

(mongo version is 3.2 and mongo java driver version is 3.4.2)

thanks

Jeff Yemin

unread,
May 24, 2017, 9:16:39 AM5/24/17
to mongodb-user
This is a failed check for a null terminator byte of a BSON string in the document that the driver is attempting to decode.  It indicates that the document is corrupted.

Would you be able to provide a dump of the collection that you're querying?  If so, let me know and if necessary we can provide a secure location for which to upload the data.


Regards,
Jeff
Reply all
Reply to author
Forward
0 new messages