static BsonDocument sanitizeDocument(final BsonDocument document) {
    if (document == null) {
      return null;
    }
    if (document.containsKey(DOCUMENT_VERSION_FIELD)) {
      final BsonDocument clonedDoc = document.clone();
      clonedDoc.remove(DOCUMENT_VERSION_FIELD);

      return clonedDoc;
    }
    return document;
  }
static BsonDocument sanitizeDocument ( final BsonDocument document ) { if ( document == null ) { return null ; } if ( document . containsKey ( DOCUMENT_VERSION_FIELD ) ) { final BsonDocument clonedDoc = document . clone ( ) ; clonedDoc . remove ( DOCUMENT_VERSION_FIELD ) ; return clonedDoc ; } return document ; }
Given a BSON document, remove any forbidden fields and return the document. If no changes are
made, the original document reference is returned. If changes are made, a cloned copy of the
document with the changes will be returned.

@param document the document from which to remove forbidden fields

@return a BsonDocument without any forbidden fields.