michel-kraemer/bson4jackson — pull request #13 by jroper (2011-12-09 14:54:06+00:00)
Title: Optional document length parsing support

I've implemented support for issue #11. Currently bson4jackson, because it uses a BufferedInputStream, reads past the end of the document, which causes problems when reading from a stream that contains more than just the BSON document, such as when reading responses from MongoDB. This pull request adds a feature (disabled by default) to honour the document length, so that buffering can still be done for good performance. It does this by wrapping the input stream in a BoundedInputStream, that is bounded by the document length. The feature can be enabled by calling:

bsonFactory.enable(BsonParser.Feature.HONOR_DOCUMENT_LENGTH);

I've written thorough unit tests too.