Program: 54359
Project: 54359
Buggy source:
public static ReplicaSetConfig fromDocument(@Nonnull BsonDocument bson) throws BadValueException, TypesMismatchException, NoSuchKeyException, FailedToParseException {
  BsonReaderTool.checkOnlyHasFields("String_Node_Str",bson,VALID_FIELD_NAMES);
  String id=BsonReaderTool.getString(bson,ID_FIELD);
  int version=BsonReaderTool.getInteger(bson,VERSION_FIELD);
  Builder builder=new Builder(id,version);
  BsonArray uncastedMembers=BsonReaderTool.getArray(bson,MEMBERS_FIELD);
  int i=0;
  for (  BsonValue uncastedMember : uncastedMembers) {
    if (uncastedMember == null || !uncastedMember.isDocument()) {
      throw new TypesMismatchException(Integer.toString(i),"String_Node_Str",uncastedMember == null ? null : uncastedMember.getType());
    }
    builder.addMemberConfig(MemberConfig.fromDocument(uncastedMember.asDocument()));
    i++;
  }
  BsonDocument settings;
  try {
    settings=BsonReaderTool.getDocument(bson,SETTINGS_FIELD);
  }
 catch (  NoSuchKeyException ex) {
    settings=DefaultBsonValues.EMPTY_DOC;
  }
  builder.setHbTimeout(BsonReaderTool.getInteger(settings,HEARTHBEAT_TIMEOUT_FIELD,DEFAULT_HEARTBEAT_TIMEOUT_MILLIS)).setChainingAllowed(BsonReaderTool.getBoolean(settings,CHAINING_ALLOWED_FIELD,DEFAULT_CHAINING_ALLOWED));
  BsonDocument uncastedGetLastErrorDefaults=BsonReaderTool.getDocument(settings,GET_LAST_ERROR_DEFAULTS_FIELD);
  WriteConcern wc=WriteConcern.fromDocument(uncastedGetLastErrorDefaults);
  builder.setWriteConcern(wc);
  BsonDocument uncastedCustomWriteConcerns;
  try {
    uncastedCustomWriteConcerns=BsonReaderTool.getDocument(settings,GET_LAST_ERROR_MODES_FIELD);
  }
 catch (  NoSuchKeyException ex) {
    uncastedCustomWriteConcerns=DefaultBsonValues.EMPTY_DOC;
  }
  Map<String,ReplicaSetTagPattern> customWriteConcernsBuilder=parseCustomWriteConcerns(uncastedCustomWriteConcerns);
  for (  Map.Entry<String,ReplicaSetTagPattern> customWriteConcern : customWriteConcernsBuilder.entrySet()) {
    builder.putCustomWriteConcern(customWriteConcern.getKey(),customWriteConcern.getValue());
  }
  builder.setProtocolVersion(BsonReaderTool.getLong(bson,PROTOCOL_VERSION_FIELD));
  return builder.build();
}

Fixed version (ground truth):
public static ReplicaSetConfig fromDocument(@Nonnull BsonDocument bson) throws BadValueException, TypesMismatchException, NoSuchKeyException, FailedToParseException {
  BsonReaderTool.checkOnlyHasFields("String_Node_Str",bson,VALID_FIELD_NAMES);
  String id=BsonReaderTool.getString(bson,ID_FIELD);
  int version=BsonReaderTool.getInteger(bson,VERSION_FIELD);
  Builder builder=new Builder(id,version);
  BsonArray uncastedMembers=BsonReaderTool.getArray(bson,MEMBERS_FIELD);
  int i=0;
  for (  BsonValue uncastedMember : uncastedMembers) {
    if (uncastedMember == null || !uncastedMember.isDocument()) {
      throw new TypesMismatchException(Integer.toString(i),"String_Node_Str",uncastedMember == null ? null : uncastedMember.getType());
    }
    builder.addMemberConfig(MemberConfig.fromDocument(uncastedMember.asDocument()));
    i++;
  }
  BsonDocument settings;
  try {
    settings=BsonReaderTool.getDocument(bson,SETTINGS_FIELD);
  }
 catch (  NoSuchKeyException ex) {
    settings=DefaultBsonValues.EMPTY_DOC;
  }
  builder.setHbTimeout(BsonReaderTool.getInteger(settings,HEARTHBEAT_TIMEOUT_FIELD,DEFAULT_HEARTBEAT_TIMEOUT_MILLIS)).setChainingAllowed(BsonReaderTool.getBoolean(settings,CHAINING_ALLOWED_FIELD,DEFAULT_CHAINING_ALLOWED));
  BsonDocument uncastedGetLastErrorDefaults=BsonReaderTool.getDocument(settings,GET_LAST_ERROR_DEFAULTS_FIELD);
  WriteConcern wc=WriteConcern.fromDocument(uncastedGetLastErrorDefaults);
  builder.setWriteConcern(wc);
  BsonDocument uncastedCustomWriteConcerns;
  try {
    uncastedCustomWriteConcerns=BsonReaderTool.getDocument(settings,GET_LAST_ERROR_MODES_FIELD);
  }
 catch (  NoSuchKeyException ex) {
    uncastedCustomWriteConcerns=DefaultBsonValues.EMPTY_DOC;
  }
  Map<String,ReplicaSetTagPattern> customWriteConcernsBuilder=parseCustomWriteConcerns(uncastedCustomWriteConcerns);
  for (  Map.Entry<String,ReplicaSetTagPattern> customWriteConcern : customWriteConcernsBuilder.entrySet()) {
    builder.putCustomWriteConcern(customWriteConcern.getKey(),customWriteConcern.getValue());
  }
  builder.setProtocolVersion(BsonReaderTool.getLong(bson,PROTOCOL_VERSION_FIELD,0));
  return builder.build();
}