Program: 90496
Project: 90496
Buggy source:
/** 
 * 创建数据库表.
 * @throws
	 * @throws IOException
 */
private void _createTable(List<DBTable> tables) throws Exception {
  Map<String,Map<Integer,Map<String,Integer>>> tableCluster=this.dbRouter.getTableCluster();
  String clusterName=null;
  Map<Integer,Map<String,Integer>> oneDbTables=null;
  for (  DBTable table : tables) {
    clusterName=table.getCluster();
    if (table.getShardingNum() > 0) {
      oneDbTables=tableCluster.get(clusterName);
      DBClusterInfo dbClusterInfo=this.dbClusterInfo.get(clusterName);
      if (oneDbTables == null || dbClusterInfo == null) {
        throw new DBClusterException("String_Node_Str" + clusterName);
      }
      for (      Integer dbIndex : oneDbTables.keySet()) {
        for (        DBClusterRegionInfo region : dbClusterInfo.getDbRegions()) {
          Connection dbConn=region.getMasterConnection().get(dbIndex).getDatasource().getConnection();
          int tableNum=oneDbTables.get(dbIndex).get(table.getName());
          this.dbGenerator.syncTable(dbConn,table,tableNum);
          dbConn.close();
        }
        for (        DBClusterRegionInfo region : dbClusterInfo.getDbRegions()) {
          List<List<DBConnectionInfo>> slaveDbs=region.getSlaveConnection();
          for (          List<DBConnectionInfo> slaveConns : slaveDbs) {
            for (            DBConnectionInfo dbConnInfo : slaveConns) {
              Connection dbConn=dbConnInfo.getDatasource().getConnection();
              int tableNum=oneDbTables.get(dbIndex).get(table.getName());
              this.dbGenerator.syncTable(dbConn,table,tableNum);
              dbConn.close();
            }
          }
        }
      }
    }
 else {
      DBClusterInfo dbClusterInfo=this.dbClusterInfo.get(clusterName);
      if (dbClusterInfo == null) {
        throw new DBClusterException("String_Node_Str" + clusterName);
      }
      DBConnectionInfo dbConnInfo=dbClusterInfo.getMasterGlobalConnection();
      if (dbConnInfo != null) {
        DataSource globalDs=dbConnInfo.getDatasource();
        if (globalDs != null) {
          Connection conn=globalDs.getConnection();
          this.dbGenerator.syncTable(conn,table);
          conn.close();
        }
      }
      List<DBConnectionInfo> slaveDbs=dbClusterInfo.getSlaveGlobalConnection();
      if (slaveDbs != null && !slaveDbs.isEmpty()) {
        for (        DBConnectionInfo slaveConnInfo : slaveDbs) {
          Connection conn=slaveConnInfo.getDatasource().getConnection();
          this.dbGenerator.syncTable(conn,table);
          conn.close();
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * 创建数据库表.
 * @throws
	 * @throws IOException
 */
private void _createTable(List<DBTable> tables) throws Exception {
  String clusterName=null;
  Map<Integer,Map<String,Integer>> oneDbTables=null;
  for (  DBTable table : tables) {
    clusterName=table.getCluster();
    if (table.getShardingNum() > 0) {
      oneDbTables=tableCluster.get(clusterName);
      DBClusterInfo dbClusterInfo=this.dbClusterInfo.get(clusterName);
      if (oneDbTables == null || dbClusterInfo == null) {
        throw new DBClusterException("String_Node_Str" + clusterName);
      }
      for (      Integer dbIndex : oneDbTables.keySet()) {
        for (        DBClusterRegionInfo region : dbClusterInfo.getDbRegions()) {
          Connection dbConn=region.getMasterConnection().get(dbIndex).getDatasource().getConnection();
          int tableNum=oneDbTables.get(dbIndex).get(table.getName());
          this.dbGenerator.syncTable(dbConn,table,tableNum);
          dbConn.close();
        }
        for (        DBClusterRegionInfo region : dbClusterInfo.getDbRegions()) {
          List<List<DBConnectionInfo>> slaveDbs=region.getSlaveConnection();
          for (          List<DBConnectionInfo> slaveConns : slaveDbs) {
            for (            DBConnectionInfo dbConnInfo : slaveConns) {
              Connection dbConn=dbConnInfo.getDatasource().getConnection();
              int tableNum=oneDbTables.get(dbIndex).get(table.getName());
              this.dbGenerator.syncTable(dbConn,table,tableNum);
              dbConn.close();
            }
          }
        }
      }
    }
 else {
      DBClusterInfo dbClusterInfo=this.dbClusterInfo.get(clusterName);
      if (dbClusterInfo == null) {
        throw new DBClusterException("String_Node_Str" + clusterName);
      }
      DBConnectionInfo dbConnInfo=dbClusterInfo.getMasterGlobalConnection();
      if (dbConnInfo != null) {
        DataSource globalDs=dbConnInfo.getDatasource();
        if (globalDs != null) {
          Connection conn=globalDs.getConnection();
          this.dbGenerator.syncTable(conn,table);
          conn.close();
        }
      }
      List<DBConnectionInfo> slaveDbs=dbClusterInfo.getSlaveGlobalConnection();
      if (slaveDbs != null && !slaveDbs.isEmpty()) {
        for (        DBConnectionInfo slaveConnInfo : slaveDbs) {
          Connection conn=slaveConnInfo.getDatasource().getConnection();
          this.dbGenerator.syncTable(conn,table);
          conn.close();
        }
      }
    }
  }
}