Program: 94269
Project: 94269
Buggy source:
/** 
 * Creates the table for the given replication group member, if it does not exist. Otherwise, if the table exists but has an incorrect  {@link StreamSpecification}, update the table with the correct   {@link StreamSpecification}.
 * @param group the replication group containing the table that needs to be created
 * @param createMember the replication group member representing the table that needs to be created
 * @param awsAccess AWS access class providing DynamoDB clients to create the table
 */
public static void createTableIfNotExists(DynamoDBReplicationGroup group,DynamoDBReplicationGroupMember createMember,AccountMapToAwsAccess awsAccess) throws Exception {
  String accountNumber=new DynamoDBArn().withArnString(createMember.getArn()).getAccountNumber();
  AwsAccess accountAccess=awsAccess.getAccessAccount(accountNumber);
  coordinatorAssert(accountAccess != null,"String_Node_Str" + accountNumber);
  AmazonDynamoDB ddbClient=accountAccess.getDynamoDB(createMember.getEndpoint());
  String tableName=new DynamoDBArn().withArnString(createMember.getArn()).getTableName();
  StreamSpecification replicationStreamSpec=new StreamSpecification().withStreamEnabled(defaultStreamEnabled).withStreamViewType(defaultStreamViewType);
  try {
    DescribeTableResult result=ddbClient.describeTable(tableName);
    TableDescription table=result.getTable();
    coordinatorAssert(table.getAttributeDefinitions().equals(AttributeDefinitionDescription.convertToAttributeDefinitions(group.getAttributeDefinitions())),"String_Node_Str");
    coordinatorAssert(table.getKeySchema().equals(KeySchemaElementDescription.convertToKeySchemaElements(group.getKeySchema())),"String_Node_Str");
    if (createMember.getStreamsEnabled()) {
      StreamSpecification streamSpec=result.getTable().getStreamSpecification();
      if (streamSpec == null || !replicationStreamSpec.equals(streamSpec)) {
        ddbClient.updateTable(new UpdateTableRequest().withTableName(tableName).withStreamSpecification(replicationStreamSpec));
      }
    }
  }
 catch (  ResourceNotFoundException e) {
    coordinatorAssert(createMember.getProvisionedThroughput() != null,"String_Node_Str");
    CreateTableRequest createTableRequest=new CreateTableRequest().withTableName(tableName).withAttributeDefinitions(AttributeDefinitionDescription.convertToAttributeDefinitions(group.getAttributeDefinitions())).withKeySchema(KeySchemaElementDescription.convertToKeySchemaElements(group.getKeySchema())).withProvisionedThroughput(createMember.getProvisionedThroughput().toProvisionedThroughput());
    if (createMember.getGlobalSecondaryIndexes() != null && !createMember.getGlobalSecondaryIndexes().isEmpty()) {
      createTableRequest.setGlobalSecondaryIndexes(SecondaryIndexDesc.toGSIList(createMember.getGlobalSecondaryIndexes()));
    }
    if (createMember.getLocalSecondaryIndexes() != null && !createMember.getLocalSecondaryIndexes().isEmpty()) {
      createTableRequest.setLocalSecondaryIndexes(SecondaryIndexDesc.toLSIList(createMember.getLocalSecondaryIndexes()));
    }
    if (createMember.getStreamsEnabled()) {
      createTableRequest.setStreamSpecification(replicationStreamSpec);
    }
    ddbClient.createTable(createTableRequest);
  }
  waitForTableActive(ddbClient,tableName,WAITING_TIME_OUT);
}

Fixed version (ground truth):
/** 
 * Creates the table for the given replication group member, if it does not exist. Otherwise, if the table exists but has an incorrect  {@link StreamSpecification}, update the table with the correct   {@link StreamSpecification}.
 * @param group the replication group containing the table that needs to be created
 * @param createMember the replication group member representing the table that needs to be created
 * @param awsAccess AWS access class providing DynamoDB clients to create the table
 */
public static void createTableIfNotExists(DynamoDBReplicationGroup group,DynamoDBReplicationGroupMember createMember,AccountMapToAwsAccess awsAccess) throws Exception {
  String accountNumber=new DynamoDBArn().withArnString(createMember.getArn()).getAccountNumber();
  AwsAccess accountAccess=awsAccess.getAccessAccount(accountNumber);
  coordinatorAssert(accountAccess != null,"String_Node_Str" + accountNumber);
  AmazonDynamoDB ddbClient=accountAccess.getDynamoDB(createMember.getEndpoint());
  String tableName=new DynamoDBArn().withArnString(createMember.getArn()).getTableName();
  StreamSpecification replicationStreamSpec=new StreamSpecification().withStreamEnabled(defaultStreamEnabled).withStreamViewType(defaultStreamViewType);
  try {
    DescribeTableResult result=ddbClient.describeTable(tableName);
    TableDescription table=result.getTable();
    coordinatorAssert(table.getKeySchema().equals(KeySchemaElementDescription.convertToKeySchemaElements(group.getKeySchema())),"String_Node_Str");
    if (createMember.getStreamsEnabled()) {
      StreamSpecification streamSpec=result.getTable().getStreamSpecification();
      if (streamSpec == null || !replicationStreamSpec.equals(streamSpec)) {
        ddbClient.updateTable(new UpdateTableRequest().withTableName(tableName).withStreamSpecification(replicationStreamSpec));
      }
    }
  }
 catch (  ResourceNotFoundException e) {
    coordinatorAssert(createMember.getProvisionedThroughput() != null,"String_Node_Str");
    CreateTableRequest createTableRequest=new CreateTableRequest().withTableName(tableName).withProvisionedThroughput(createMember.getProvisionedThroughput().toProvisionedThroughput());
    List<KeySchemaElement> keySchemaList=KeySchemaElementDescription.convertToKeySchemaElements(group.getKeySchema());
    createTableRequest.setKeySchema(keySchemaList);
    Set<String> requiredAttributeNames=new HashSet<String>();
    for (    KeySchemaElement keySchema : keySchemaList) {
      requiredAttributeNames.add(keySchema.getAttributeName());
    }
    if (createMember.getGlobalSecondaryIndexes() != null && !createMember.getGlobalSecondaryIndexes().isEmpty()) {
      List<GlobalSecondaryIndex> gsiList=SecondaryIndexDesc.toGSIList(createMember.getGlobalSecondaryIndexes());
      createTableRequest.setGlobalSecondaryIndexes(gsiList);
      for (      GlobalSecondaryIndex index : gsiList) {
        for (        KeySchemaElement keySchema : index.getKeySchema()) {
          requiredAttributeNames.add(keySchema.getAttributeName());
        }
      }
    }
    if (createMember.getLocalSecondaryIndexes() != null && !createMember.getLocalSecondaryIndexes().isEmpty()) {
      List<LocalSecondaryIndex> lsiList=SecondaryIndexDesc.toLSIList(createMember.getLocalSecondaryIndexes());
      createTableRequest.setLocalSecondaryIndexes(lsiList);
      for (      LocalSecondaryIndex index : lsiList) {
        for (        KeySchemaElement keySchema : index.getKeySchema()) {
          requiredAttributeNames.add(keySchema.getAttributeName());
        }
      }
    }
    if (createMember.getStreamsEnabled()) {
      createTableRequest.setStreamSpecification(replicationStreamSpec);
    }
    List<AttributeDefinition> attrDefnList=AttributeDefinitionDescription.convertToAttributeDefinitions(group.getAttributeDefinitions());
    Iterator<AttributeDefinition> iter=attrDefnList.iterator();
    while (iter.hasNext()) {
      AttributeDefinition attrDefn=iter.next();
      if (!requiredAttributeNames.contains(attrDefn.getAttributeName())) {
        iter.remove();
      }
    }
    createTableRequest.setAttributeDefinitions(attrDefnList);
    ddbClient.createTable(createTableRequest);
  }
  waitForTableActive(ddbClient,tableName,WAITING_TIME_OUT);
}