nus-yam/ex-repair huggingface dataset:
Program: 90346
Project: 90346
Buggy source:
@Override public void scale(float scaleX,float scaleY,float pivotX,float pivotY){
  this.affineTransform.scale(scaleX,scaleY);
}

Fixed version (ground truth):
@Override public void scale(float scaleX,float scaleY){
  this.affineTransform.scale(scaleX,scaleY);
}
Program: 90347
Project: 90347
Buggy source:
private void drawParentTileBitmap(Canvas canvas,Point point,Tile tile){
  Tile cachedParentTile=getCachedParentTile(tile,4);
  if (cachedParentTile != null) {
    Bitmap bitmap=this.tileCache.get(createJob(cachedParentTile));
    if (bitmap != null) {
      long translateX=tile.getShiftX(cachedParentTile) * Tile.TILE_SIZE;
      long translateY=tile.getShiftY(cachedParentTile) * Tile.TILE_SIZE;
      byte zoomLevelDiff=(byte)(tile.zoomLevel - cachedParentTile.zoomLevel);
      float scaleFactor=(float)Math.pow(2,zoomLevelDiff);
      this.matrix.reset();
      this.matrix.scale(scaleFactor,scaleFactor);
      this.matrix.translate((float)(point.x - translateX),(float)(point.y - translateY));
      canvas.drawBitmap(bitmap,this.matrix);
    }
  }
}

Fixed version (ground truth):
private void drawParentTileBitmap(Canvas canvas,Point point,Tile tile){
  Tile cachedParentTile=getCachedParentTile(tile,4);
  if (cachedParentTile != null) {
    Bitmap bitmap=this.tileCache.get(createJob(cachedParentTile));
    if (bitmap != null) {
      long translateX=tile.getShiftX(cachedParentTile) * Tile.TILE_SIZE;
      long translateY=tile.getShiftY(cachedParentTile) * Tile.TILE_SIZE;
      byte zoomLevelDiff=(byte)(tile.zoomLevel - cachedParentTile.zoomLevel);
      float scaleFactor=(float)Math.pow(2,zoomLevelDiff);
      this.matrix.reset();
      this.matrix.translate((float)(point.x - translateX),(float)(point.y - translateY));
      this.matrix.scale(scaleFactor,scaleFactor);
      canvas.drawBitmap(bitmap,this.matrix);
    }
  }
}
Program: 90348
Project: 90348
Buggy source:
public void setOverdrawFactor(double overdrawFactor){
  if (overdrawFactor <= 0) {
    throw new IllegalArgumentException("String_Node_Str" + overdrawFactor);
  }
synchronized (this) {
    this.overdrawFactor=overdrawFactor;
  }
  notifyObservers();
}

Fixed version (ground truth):
/** 
 * @throws IllegalArgumentException if the  {@code overdrawFactor} is less or equal zero.
 */
public void setOverdrawFactor(double overdrawFactor){
  if (overdrawFactor <= 0) {
    throw new IllegalArgumentException("String_Node_Str" + overdrawFactor);
  }
synchronized (this) {
    this.overdrawFactor=overdrawFactor;
  }
  notifyObservers();
}
Program: 90349
Project: 90349
Buggy source:
public synchronized void adjustMatrix(float diffX,float diffY,float scaleFactor,Dimension mapViewDimension){
  if (this.dimension == null) {
    return;
  }
  int pivotX=this.dimension.width / 2;
  int pivotY=this.dimension.height / 2;
  this.matrix.reset();
  this.matrix.scale(scaleFactor,scaleFactor,pivotX,pivotY);
  this.matrix.translate(diffX,diffY);
  float dx=(this.dimension.width - mapViewDimension.width) / -2f;
  float dy=(this.dimension.height - mapViewDimension.height) / -2f;
  this.matrix.translate(dx,dy);
}

Fixed version (ground truth):
public synchronized void adjustMatrix(float diffX,float diffY,float scaleFactor,Dimension mapViewDimension){
  if (this.dimension == null) {
    return;
  }
  this.matrix.reset();
  centerFrameBufferToMapView(mapViewDimension);
  scale(scaleFactor);
  this.matrix.translate(diffX,diffY);
}
Program: 90350
Project: 90350
Buggy source:
@Override public synchronized void destroy(){
  if (!this.persistent || !serializeMap(this.cacheDirectory,this.map)) {
    for (    File file : this.map.values()) {
      if (!file.delete()) {
        file.deleteOnExit();
      }
    }
    this.map.clear();
    File[] filesToDelete=this.cacheDirectory.listFiles(ImageFileNameFilter.INSTANCE);
    if (filesToDelete != null) {
      for (      File file : filesToDelete) {
        if (!file.delete()) {
          file.deleteOnExit();
        }
      }
    }
    if (!this.cacheDirectory.delete()) {
      this.cacheDirectory.deleteOnExit();
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void destroy(){
  if (this.bitmapGet != null) {
    this.bitmapGet.recycle();
  }
  if (this.capacity == 0) {
    return;
  }
  if (!this.persistent || !serializeMap(this.cacheDirectory,this.map)) {
    for (    File file : this.map.values()) {
      if (!file.delete()) {
        file.deleteOnExit();
      }
    }
    this.map.clear();
    if (this.cacheDirectory != null) {
      File[] filesToDelete=this.cacheDirectory.listFiles(ImageFileNameFilter.INSTANCE);
      if (filesToDelete != null) {
        for (        File file : filesToDelete) {
          if (!file.delete()) {
            file.deleteOnExit();
          }
        }
      }
      if (!this.cacheDirectory.delete()) {
        this.cacheDirectory.deleteOnExit();
      }
    }
  }
}
Program: 90351
Project: 90351
Buggy source:
@Override public synchronized void put(MapGeneratorJob mapGeneratorJob,Bitmap bitmap){
  if (this.capacity == 0) {
    return;
  }
  FileOutputStream fileOutputStream=null;
  try {
    File outputFile;
    do {
      ++this.cacheId;
      outputFile=new File(this.cacheDirectory,this.cacheId + IMAGE_FILE_NAME_EXTENSION);
    }
 while (outputFile.exists());
    this.byteBuffer.rewind();
    bitmap.copyPixelsToBuffer(this.byteBuffer);
    byte[] array=this.byteBuffer.array();
    fileOutputStream=new FileOutputStream(outputFile);
    fileOutputStream.write(array,0,array.length);
    this.map.put(mapGeneratorJob,outputFile);
  }
 catch (  IOException e) {
    LOGGER.log(Level.SEVERE,null,e);
  }
 finally {
    try {
      if (fileOutputStream != null) {
        fileOutputStream.close();
      }
    }
 catch (    IOException e) {
      LOGGER.log(Level.SEVERE,null,e);
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void put(MapGeneratorJob mapGeneratorJob,Bitmap bitmap){
  if (this.capacity == 0) {
    return;
  }
  FileOutputStream fileOutputStream=null;
  try {
    File outputFile;
    do {
      ++this.cacheId;
      outputFile=new File(this.cacheDirectory,this.cacheId + IMAGE_FILE_NAME_EXTENSION);
    }
 while (outputFile.exists());
    this.byteBuffer.rewind();
    bitmap.copyPixelsToBuffer(this.byteBuffer);
    byte[] array=this.byteBuffer.array();
    fileOutputStream=new FileOutputStream(outputFile);
    fileOutputStream.write(array,0,array.length);
    this.map.put(mapGeneratorJob,outputFile);
  }
 catch (  IOException e) {
    LOGGER.log(Level.SEVERE,"String_Node_Str",e);
    this.capacity=0;
  }
 finally {
    try {
      if (fileOutputStream != null) {
        fileOutputStream.close();
      }
    }
 catch (    IOException e) {
      LOGGER.log(Level.SEVERE,null,e);
    }
  }
}
Program: 90352
Project: 90352
Buggy source:
/** 
 * @param capacity the maximum number of entries in this cache.
 * @param mapViewId the ID of the MapView to separate caches for different MapViews.
 * @throws IllegalArgumentException if the capacity is negative.
 */
public FileSystemTileCache(int capacity,int mapViewId){
  this.capacity=getCapacity(capacity);
  String externalStorageDirectory=Environment.getExternalStorageDirectory().getAbsolutePath();
  String cacheDirectoryPath=externalStorageDirectory + CACHE_DIRECTORY + mapViewId;
  this.cacheDirectory=createDirectory(cacheDirectoryPath);
  Map<MapGeneratorJob,File> deserializedMap=deserializeMap(this.cacheDirectory);
  if (deserializedMap == null) {
    this.map=createMap(this.capacity);
  }
 else {
    this.map=deserializedMap;
  }
  this.byteBuffer=ByteBuffer.allocate(TILE_SIZE_IN_BYTES);
  this.bitmapGet=Bitmap.createBitmap(Tile.TILE_SIZE,Tile.TILE_SIZE,Config.RGB_565);
}

Fixed version (ground truth):
/** 
 * @param capacity the maximum number of entries in this cache.
 * @param mapViewId the ID of the MapView to separate caches for different MapViews.
 * @throws IllegalArgumentException if the capacity is negative.
 */
public FileSystemTileCache(int capacity,int mapViewId){
  this.mapViewId=mapViewId;
  this.capacity=checkCapacity(capacity);
  if (this.capacity > 0 && this.cacheDirectory != null) {
    Map<MapGeneratorJob,File> deserializedMap=deserializeMap(this.cacheDirectory);
    if (deserializedMap == null) {
      this.map=createMap(this.capacity);
    }
 else {
      this.map=deserializedMap;
    }
    this.byteBuffer=ByteBuffer.allocate(TILE_SIZE_IN_BYTES);
    this.bitmapGet=Bitmap.createBitmap(Tile.TILE_SIZE,Tile.TILE_SIZE,Config.RGB_565);
  }
 else {
    this.byteBuffer=null;
    this.bitmapGet=null;
    this.map=createMap(0);
  }
}
Program: 90353
Project: 90353
Buggy source:
@Override public synchronized void setCapacity(int capacity){
  if (this.capacity == capacity) {
    return;
  }
  this.capacity=getCapacity(capacity);
  Map<MapGeneratorJob,File> newMap=createMap(this.capacity);
  newMap.putAll(this.map);
  this.map=newMap;
}

Fixed version (ground truth):
@Override public synchronized void setCapacity(int capacity){
  if (this.capacity == capacity) {
    return;
  }
  this.capacity=checkCapacity(capacity);
  if (this.capacity != 0) {
    Map<MapGeneratorJob,File> newMap=createMap(this.capacity);
    if (this.map != null) {
      newMap.putAll(this.map);
    }
    this.map=newMap;
  }
}
Program: 90354
Project: 90354
Buggy source:
private void restoreMapView(MapView mapView){
  SharedPreferences sharedPreferences=getSharedPreferences(PREFERENCES_FILE,MODE_PRIVATE);
  if (containsMapViewPosition(sharedPreferences)) {
    if (sharedPreferences.contains(KEY_MAP_FILE)) {
      mapView.setMapFile(new File(sharedPreferences.getString(KEY_MAP_FILE,null)));
    }
    float latitude=sharedPreferences.getFloat(KEY_LATITUDE,0);
    float longitude=sharedPreferences.getFloat(KEY_LONGITUDE,0);
    int zoomLevel=sharedPreferences.getInt(KEY_ZOOM_LEVEL,-1);
    GeoPoint geoPoint=new GeoPoint(latitude,longitude);
    MapPosition mapPosition=new MapPosition(geoPoint,(byte)zoomLevel);
    mapView.getMapViewPosition().setMapPosition(mapPosition);
  }
}

Fixed version (ground truth):
private void restoreMapView(MapView mapView){
  SharedPreferences sharedPreferences=getSharedPreferences(PREFERENCES_FILE,MODE_PRIVATE);
  if (isCompatible(sharedPreferences) && containsMapViewPosition(sharedPreferences)) {
    if (sharedPreferences.contains(KEY_MAP_FILE)) {
      mapView.setMapFile(new File(sharedPreferences.getString(KEY_MAP_FILE,null)));
    }
    float latitude=sharedPreferences.getFloat(KEY_LATITUDE,0);
    float longitude=sharedPreferences.getFloat(KEY_LONGITUDE,0);
    int zoomLevel=sharedPreferences.getInt(KEY_ZOOM_LEVEL,-1);
    GeoPoint geoPoint=new GeoPoint(latitude,longitude);
    MapPosition mapPosition=new MapPosition(geoPoint,(byte)zoomLevel);
    mapView.getMapViewPosition().setMapPosition(mapPosition);
  }
}
Program: 90355
Project: 90355
Buggy source:
@Override protected void onPause(){
  super.onPause();
  if (this.mapViews.isEmpty()) {
    return;
  }
  for (int i=0, n=this.mapViews.size(); i < n; ++i) {
    this.mapViews.get(i).onPause();
  }
  Editor editor=getSharedPreferences(PREFERENCES_FILE,MODE_PRIVATE).edit();
  editor.clear();
  MapView mapView=this.mapViews.get(0);
  MapPosition mapPosition=mapView.getMapViewPosition().getMapPosition();
  GeoPoint geoPoint=mapPosition.geoPoint;
  editor.putFloat(KEY_LATITUDE,(float)geoPoint.latitude);
  editor.putFloat(KEY_LONGITUDE,(float)geoPoint.longitude);
  editor.putInt(KEY_ZOOM_LEVEL,mapPosition.zoomLevel);
  if (mapView.getMapFile() != null) {
    editor.putString(KEY_MAP_FILE,mapView.getMapFile().getAbsolutePath());
  }
  editor.commit();
}

Fixed version (ground truth):
@Override protected void onPause(){
  super.onPause();
  if (this.mapViews.isEmpty()) {
    return;
  }
  for (int i=0, n=this.mapViews.size(); i < n; ++i) {
    this.mapViews.get(i).onPause();
  }
  Editor editor=getSharedPreferences(PREFERENCES_FILE,MODE_PRIVATE).edit();
  editor.clear();
  editor.putInt(PREFERENCES_VERSION_KEY,PREFERENCES_VERSION_NUMBER);
  MapView mapView=this.mapViews.get(0);
  MapPosition mapPosition=mapView.getMapViewPosition().getMapPosition();
  GeoPoint geoPoint=mapPosition.geoPoint;
  editor.putFloat(KEY_LATITUDE,(float)geoPoint.latitude);
  editor.putFloat(KEY_LONGITUDE,(float)geoPoint.longitude);
  editor.putInt(KEY_ZOOM_LEVEL,mapPosition.zoomLevel);
  if (mapView.getMapFile() != null) {
    editor.putString(KEY_MAP_FILE,mapView.getMapFile().getAbsolutePath());
  }
  editor.commit();
}
Program: 90360
Project: 90360
Buggy source:
@Override public Number save(Object entity){
  CheckUtil.checkShardingEntity(entity);
  String clusterName=entityMetaManager.getClusterName(entity.getClass());
  Object shardingKey=entityMetaManager.getShardingValue(entity);
  IShardingKey<Object> sk=new ShardingKey<Object>(clusterName,shardingKey);
  CheckUtil.checkShardingKey(sk);
  return this.shardingUpdater.save(entity,sk).getValueAsNumber();
}

Fixed version (ground truth):
@Override public Number save(Object entity){
  CheckUtil.checkShardingEntity(entity);
  String clusterName=entityMetaManager.getClusterName(entity.getClass());
  Object shardingKey=entityMetaManager.getShardingValue(entity);
  IShardingKey<Object> sk=new ShardingKey<Object>(clusterName,shardingKey);
  CheckUtil.checkShardingKey(sk);
  PKValue pkValue=this.shardingUpdater.save(entity,sk);
  if (pkValue != null) {
    return pkValue.getValueAsNumber();
  }
  return null;
}
Program: 90361
Project: 90361
Buggy source:
@Test public void testSave() throws Exception {
  TestGlobalEntity globalEntity=createGlobalEntity();
  globalEntity.setId(pinusClient.genClusterUniqueLongId("String_Node_Str"));
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  TestEntity shardingEntity=createEntity();
  shardingEntity.setId(pinusClient.genClusterUniqueLongId("String_Node_Str"));
  pinusClient.save(globalEntity);
  System.out.println(globalEntity.getId());
  pinusClient.save(globalUKEntity);
  System.out.println(globalUKEntity);
  pinusClient.save(shardingEntity);
  System.out.println(shardingEntity.getId());
}

Fixed version (ground truth):
@Test public void testSave() throws Exception {
  TestGlobalEntity globalEntity=createGlobalEntity();
  globalEntity.setId(pinusClient.genClusterUniqueLongId("String_Node_Str"));
  TestGlobalUnionKeyEntity globalUKEntity=createGlobalUnionKeyEntity();
  TestEntity shardingEntity=createEntity();
  shardingEntity.setId(pinusClient.genClusterUniqueLongId("String_Node_Str"));
  System.out.println(globalEntity.getId());
  pinusClient.save(globalUKEntity);
  System.out.println(globalUKEntity);
  System.out.println(shardingEntity.getId());
}
Program: 90362
Project: 90362
Buggy source:
/** 
 * relase resource. include database connection,zookeeper connection and cache connection.
 */
@Override public void shutdown() throws DBClusterException {
  if (this.primaryCache != null)   this.primaryCache.close();
  if (this.secondCache != null)   this.secondCache.close();
  try {
    for (    DBClusterInfo dbClusterInfo : this.dbClusterInfoC.values()) {
      DBInfo masterGlobal=dbClusterInfo.getMasterGlobalDBInfo();
      if (masterGlobal != null)       closeDataSource(masterGlobal);
      List<DBInfo> slaveDbs=dbClusterInfo.getSlaveGlobalDBInfo();
      if (slaveDbs != null && !slaveDbs.isEmpty()) {
        for (        DBInfo slaveGlobal : slaveDbs) {
          closeDataSource(slaveGlobal);
        }
      }
      for (      DBRegionInfo regionInfo : dbClusterInfo.getDbRegions()) {
        for (        DBInfo dbConnInfo : regionInfo.getMasterDBInfos()) {
          closeDataSource(dbConnInfo);
        }
        for (        List<DBInfo> dbConnInfos : regionInfo.getSlaveDBInfos()) {
          for (          DBInfo dbConnInfo : dbConnInfos) {
            closeDataSource(dbConnInfo);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    throw new DBClusterException("String_Node_Str",e);
  }
  DBResourceCache.clear();
  CloseableUtils.closeQuietly(this.curatorClient);
}

Fixed version (ground truth):
/** 
 * relase resource. include database connection,zookeeper connection and cache connection.
 */
@Override public void shutdown() throws DBClusterException {
  if (this.primaryCache != null)   this.primaryCache.close();
  if (this.secondCache != null)   this.secondCache.close();
  try {
    for (    DBClusterInfo dbClusterInfo : this.dbClusterInfoC.values()) {
      DBInfo masterGlobal=dbClusterInfo.getMasterGlobalDBInfo();
      if (masterGlobal != null)       closeDataSource(masterGlobal);
      List<DBInfo> slaveDbs=dbClusterInfo.getSlaveGlobalDBInfo();
      if (slaveDbs != null && !slaveDbs.isEmpty()) {
        for (        DBInfo slaveGlobal : slaveDbs) {
          closeDataSource(slaveGlobal);
        }
      }
      for (      DBRegionInfo regionInfo : dbClusterInfo.getDbRegions()) {
        for (        DBInfo dbConnInfo : regionInfo.getMasterDBInfos()) {
          closeDataSource(dbConnInfo);
        }
        for (        List<DBInfo> dbConnInfos : regionInfo.getSlaveDBInfos()) {
          for (          DBInfo dbConnInfo : dbConnInfos) {
            closeDataSource(dbConnInfo);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    throw new DBClusterException("String_Node_Str",e);
  }
  CloseableUtils.closeQuietly(this.curatorClient);
}
Program: 90363
Project: 90363
Buggy source:
/** 
 * singleton
 * @param dbInfo
 * @return
 */
public static IDBResource valueOf(ITransaction tx,DBInfo dbInfo,String tableName) throws SQLException {
  IResourceId resId=new DBResourceId(dbInfo.getClusterName(),dbInfo.getDbName(),tableName,dbInfo.getMasterSlave());
  GlobalDBResource dbResource=null;
  if (tx != null && tx.isContain(resId)) {
    dbResource=(GlobalDBResource)tx.getDBResource(resId);
  }
 else {
    dbResource=(GlobalDBResource)DBResourceCache.getGlobalDBResource(resId);
    Connection conn=dbInfo.getDatasource().getConnection();
    conn.setAutoCommit(false);
    if (dbResource == null) {
      dbResource=new GlobalDBResource();
      dbResource.setId(resId);
      dbResource.setClusterName(dbInfo.getClusterName());
      dbResource.setDbName(dbInfo.getDbName());
      dbResource.setMasterSlave(dbInfo.getMasterSlave());
      DatabaseMetaData dbMeta=conn.getMetaData();
      String databaseProductName=dbMeta.getDatabaseProductName();
      String url=dbMeta.getURL().substring(13);
      String host=url.substring(0,url.indexOf("String_Node_Str"));
      String catalog=conn.getCatalog();
      dbResource.setDatabaseProductName(databaseProductName);
      dbResource.setHost(host);
      dbResource.setCatalog(catalog);
      DBResourceCache.putGlobalDBResource(resId,dbResource);
    }
    dbResource.setConnection(conn);
  }
  return dbResource;
}

Fixed version (ground truth):
/** 
 * singleton
 * @param dbInfo
 * @return
 */
public static IDBResource valueOf(ITransaction tx,DBInfo dbInfo,String tableName) throws SQLException {
  IResourceId resId=new DBResourceId(dbInfo.getClusterName(),dbInfo.getDbName(),tableName,dbInfo.getMasterSlave());
  GlobalDBResource dbResource=null;
  if (tx != null && tx.isContain(resId)) {
    dbResource=(GlobalDBResource)tx.getDBResource(resId);
  }
 else {
    Connection conn=dbInfo.getDatasource().getConnection();
    conn.setAutoCommit(false);
    dbResource=new GlobalDBResource();
    dbResource.setId(resId);
    dbResource.setClusterName(dbInfo.getClusterName());
    dbResource.setDbName(dbInfo.getDbName());
    dbResource.setMasterSlave(dbInfo.getMasterSlave());
    dbResource.setConnection(conn);
  }
  return dbResource;
}
Program: 90364
Project: 90364
Buggy source:
public static ShardingDBResource valueOf(ITransaction tx,DBInfo dbInfo,DBRegionInfo regionInfo,String tableName,int tableIndex) throws SQLException {
  IResourceId resId=new DBResourceId(dbInfo.getClusterName(),dbInfo.getDbName(),regionInfo.getCapacity(),tableName,tableIndex,dbInfo.getMasterSlave());
  ShardingDBResource dbResource=null;
  if (tx != null && tx.isContain(resId)) {
    dbResource=(ShardingDBResource)tx.getDBResource(resId);
  }
 else {
    dbResource=(ShardingDBResource)DBResourceCache.getShardingDBResource(resId);
    Connection conn=dbInfo.getDatasource().getConnection();
    conn.setAutoCommit(false);
    if (dbResource == null) {
      dbResource=new ShardingDBResource();
      dbResource.setId(resId);
      dbResource.setClusterName(dbInfo.getClusterName());
      dbResource.setDbName(dbInfo.getDbName());
      dbResource.setRegionCapacity(regionInfo.getCapacity());
      dbResource.setTableName(tableName);
      dbResource.setTableIndex(tableIndex);
      dbResource.setMasterSlave(dbInfo.getMasterSlave());
      DatabaseMetaData dbMeta=conn.getMetaData();
      String databaseProductName=dbMeta.getDatabaseProductName();
      String url=dbMeta.getURL().substring(13);
      String host=url.substring(0,url.indexOf("String_Node_Str"));
      String catalog=conn.getCatalog();
      dbResource.setDatabaseProductName(databaseProductName);
      dbResource.setHost(host);
      dbResource.setCatalog(catalog);
      DBResourceCache.putShardingDBResource(resId,dbResource);
    }
    dbResource.setConnection(conn);
  }
  return dbResource;
}

Fixed version (ground truth):
public static ShardingDBResource valueOf(ITransaction tx,DBInfo dbInfo,DBRegionInfo regionInfo,String tableName,int tableIndex) throws SQLException {
  IResourceId resId=new DBResourceId(dbInfo.getClusterName(),dbInfo.getDbName(),regionInfo.getCapacity(),tableName,tableIndex,dbInfo.getMasterSlave());
  ShardingDBResource dbResource=null;
  if (tx != null && tx.isContain(resId)) {
    dbResource=(ShardingDBResource)tx.getDBResource(resId);
  }
 else {
    Connection conn=dbInfo.getDatasource().getConnection();
    conn.setAutoCommit(false);
    dbResource=new ShardingDBResource();
    dbResource.setId(resId);
    dbResource.setClusterName(dbInfo.getClusterName());
    dbResource.setDbName(dbInfo.getDbName());
    dbResource.setRegionCapacity(regionInfo.getCapacity());
    dbResource.setTableName(tableName);
    dbResource.setTableIndex(tableIndex);
    dbResource.setMasterSlave(dbInfo.getMasterSlave());
    dbResource.setConnection(conn);
  }
  return dbResource;
}
Program: 90365
Project: 90365
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + clusterName + "String_Node_Str"+ dbName+ "String_Node_Str"+ tableName+ "String_Node_Str"+ tableIndex+ "String_Node_Str"+ regionCapacity+ "String_Node_Str"+ masterSlave+ "String_Node_Str"+ databaseProductName+ "String_Node_Str"+ host+ "String_Node_Str"+ catalog+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + clusterName + "String_Node_Str"+ dbName+ "String_Node_Str"+ tableName+ "String_Node_Str"+ tableIndex+ "String_Node_Str"+ regionCapacity+ "String_Node_Str"+ masterSlave+ "String_Node_Str";
}
Program: 90367
Project: 90367
Buggy source:
@Test public void testConcurrent() throws Exception {
  List<Thread> threads=Lists.newArrayList();
  for (int i=0; i < 500; i++) {
    Thread t=new Thread(new Runnable(){
      @Override public void run(){
        IQuery<TestGlobalEntity> globalQuery=pinusClient.createQuery(TestGlobalEntity.class);
        for (int i=0; i < 10000; i++) {
          globalQuery.limit(100).list();
        }
      }
    }
);
    t.start();
    threads.add(t);
    Thread.sleep(100);
  }
  for (  Thread t : threads) {
    t.join();
  }
}

Fixed version (ground truth):
@Test public void testConcurrent() throws Exception {
  List<Thread> threads=Lists.newArrayList();
  for (int i=0; i < Runtime.getRuntime().availableProcessors(); i++) {
    Thread t=new Thread(new Runnable(){
      @Override public void run(){
        IQuery<TestGlobalEntity> globalQuery=pinusClient.createQuery(TestGlobalEntity.class);
        IQuery<TestEntity> query=pinusClient.createQuery(TestEntity.class);
        for (int i=0; i < 10000; i++) {
          globalQuery.limit(10).list();
          query.limit(100,10).list();
        }
      }
    }
);
    t.start();
    threads.add(t);
    Thread.sleep(100);
  }
  for (  Thread t : threads) {
    t.join();
  }
}
Program: 90368
Project: 90368
Buggy source:
@Override public void run(){
  IQuery<TestGlobalEntity> globalQuery=pinusClient.createQuery(TestGlobalEntity.class);
  for (int i=0; i < 10000; i++) {
    globalQuery.limit(100).list();
  }
}

Fixed version (ground truth):
@Override public void run(){
  IQuery<TestGlobalEntity> globalQuery=pinusClient.createQuery(TestGlobalEntity.class);
  IQuery<TestEntity> query=pinusClient.createQuery(TestEntity.class);
  for (int i=0; i < 10000; i++) {
    globalQuery.limit(10).list();
    query.limit(100,10).list();
  }
}
Program: 90369
Project: 90369
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + username + "String_Node_Str"+ url+ "String_Node_Str"+ id+ "String_Node_Str"+ clusterName+ "String_Node_Str"+ dbName+ "String_Node_Str"+ masterSlave+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + url + "String_Node_Str"+ id+ "String_Node_Str"+ clusterName+ "String_Node_Str"+ dbName+ "String_Node_Str"+ masterSlave+ "String_Node_Str";
}
Program: 90371
Project: 90371
Buggy source:
@Override public DataSource buildAppDataSource(AppDBInfo dbInfo) throws LoadConfigException {
  BasicDataSource ds=new BasicDataSource();
  ds.setDriverClassName(dbInfo.getDbCatalog().getDriverClass());
  ds.setUsername(dbInfo.getUsername());
  ds.setPassword(dbInfo.getPassword());
  ds.setUrl(dbInfo.getUrl());
  ds.setValidationQuery("String_Node_Str");
  for (  Map.Entry<String,String> entry : dbInfo.getConnPoolInfo().entrySet()) {
    try {
      setConnectionParam(ds,entry.getKey(),entry.getValue());
    }
 catch (    Exception e) {
      LOG.warn("String_Node_Str" + entry);
    }
  }
  return ds;
}

Fixed version (ground truth):
@Override public DataSource buildAppDataSource(AppDBInfo dbInfo) throws LoadConfigException {
  BasicDataSource ds=new BasicDataSource();
  ds.setDriverClassName(dbInfo.getDbCatalog().getDriverClass());
  ds.setUsername(dbInfo.getUsername());
  ds.setPassword(dbInfo.getPassword());
  ds.setUrl(dbInfo.getUrl());
  ds.setValidationQuery("String_Node_Str");
  for (  Map.Entry<String,String> entry : dbInfo.getConnPoolInfo().entrySet()) {
    try {
      setConnectionParam(ds,entry.getKey(),entry.getValue());
    }
 catch (    Exception e) {
      throw new LoadConfigException(e);
    }
  }
  return ds;
}
Program: 90372
Project: 90372
Buggy source:
@Override public DataSource buildAppDataSource(AppDBInfo dbInfo) throws LoadConfigException {
  DruidDataSource ds=new DruidDataSource();
  ds.setDriverClassName(dbInfo.getDbCatalog().getDriverClass());
  ds.setUsername(dbInfo.getUsername());
  ds.setPassword(dbInfo.getPassword());
  ds.setUrl(dbInfo.getUrl());
  for (  Map.Entry<String,String> entry : dbInfo.getConnPoolInfo().entrySet()) {
    if (entry.getKey().equals("String_Node_Str")) {
      try {
        BeansUtil.setProperty(ds,entry.getKey(),Class.forName(entry.getValue()).newInstance());
      }
 catch (      Exception e) {
        throw new LoadConfigException("String_Node_Str");
      }
    }
 else {
      try {
        setConnectionParam(ds,entry.getKey(),entry.getValue());
      }
 catch (      Exception e) {
        LOG.warn("String_Node_Str" + entry);
      }
    }
  }
  ds.setValidationQuery("String_Node_Str");
  return ds;
}

Fixed version (ground truth):
@Override public DataSource buildAppDataSource(AppDBInfo dbInfo) throws LoadConfigException {
  DruidDataSource ds=new DruidDataSource();
  ds.setDriverClassName(dbInfo.getDbCatalog().getDriverClass());
  ds.setUsername(dbInfo.getUsername());
  ds.setPassword(dbInfo.getPassword());
  ds.setUrl(dbInfo.getUrl());
  for (  Map.Entry<String,String> entry : dbInfo.getConnPoolInfo().entrySet()) {
    if (entry.getKey().equals("String_Node_Str")) {
      try {
        BeansUtil.setProperty(ds,entry.getKey(),Class.forName(entry.getValue()).newInstance());
      }
 catch (      Exception e) {
        throw new LoadConfigException("String_Node_Str");
      }
    }
 else {
      try {
        setConnectionParam(ds,entry.getKey(),entry.getValue());
      }
 catch (      Exception e) {
        throw new LoadConfigException(e);
      }
    }
  }
  ds.setValidationQuery("String_Node_Str");
  return ds;
}
Program: 90373
Project: 90373
Buggy source:
@Override public void afterPropertiesSet() throws Exception {
  super.init();
  DefaultListableBeanFactory beanFactory=(DefaultListableBeanFactory)appCtx.getAutowireCapableBeanFactory();
  IDBConnectionPool dbConnectionPool=this.getDBCluster().getDBConnectionPool();
  IContainer<DataSource> dsC=dbConnectionPool.getAllDataSources();
  BeanDefinition dsBean=null;
  DataSource ds=null;
  for (  String key : dsC.keys()) {
    ds=dsC.find(key);
    dsBean=createBeanDef(ds);
    ((AbstractBeanDefinition)dsBean).setDestroyMethodName("String_Node_Str");
    beanFactory.registerBeanDefinition(key,dsBean);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",key);
    }
  }
}

Fixed version (ground truth):
@Override public void afterPropertiesSet() throws Exception {
  super.init();
  DefaultListableBeanFactory beanFactory=(DefaultListableBeanFactory)appCtx.getAutowireCapableBeanFactory();
  IDBConnectionPool dbConnectionPool=this.getDBCluster().getDBConnectionPool();
  IContainer<DataSource> dsC=dbConnectionPool.getAllDataSources();
  BeanDefinition dsBean=null;
  DataSource ds=null;
  for (  String key : dsC.keys()) {
    ds=dsC.find(key);
    dsBean=createBeanDef(ds);
    ((AbstractBeanDefinition)dsBean).setDestroyMethodName("String_Node_Str");
    beanFactory.registerBeanDefinition(key,dsBean);
    LOG.info("String_Node_Str",key);
  }
}
Program: 90374
Project: 90374
Buggy source:
@Override public IDBResource getSlaveGlobalDBResource(String clusterName,String tableName,EnumDBMasterSlave masterSlave) throws DBClusterException {
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  List<DBInfo> slaveDbs=dbClusterInfo.getSlaveGlobalDBInfo();
  if (slaveDbs == null || slaveDbs.isEmpty()) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  DBInfo slaveDBInfo=null;
  if (EnumDBMasterSlave.AUTO == masterSlave) {
    slaveDBInfo=slaveDbs.get(r.nextInt(slaveDbs.size() - 1));
  }
 else {
    slaveDBInfo=slaveDbs.get(masterSlave.getValue());
  }
  IDBResource slaveDBResource;
  try {
    ITransaction tx=(ITransaction)txManager.getTransaction();
    slaveDBResource=GlobalDBResource.valueOf(tx,slaveDBInfo,tableName);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
catch (  SystemException e) {
    throw new DBOperationException(e);
  }
  return slaveDBResource;
}

Fixed version (ground truth):
@Override public IDBResource getSlaveGlobalDBResource(String clusterName,String tableName,EnumDBMasterSlave masterSlave) throws DBClusterException {
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  List<DBInfo> slaveDbs=dbClusterInfo.getSlaveGlobalDBInfo();
  if (slaveDbs == null || slaveDbs.isEmpty()) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  DBInfo slaveDBInfo=null;
  if (EnumDBMasterSlave.AUTO == masterSlave) {
    slaveDBInfo=slaveDbs.get(r.nextInt(slaveDbs.size()));
  }
 else {
    slaveDBInfo=slaveDbs.get(masterSlave.getValue());
  }
  IDBResource slaveDBResource;
  try {
    ITransaction tx=(ITransaction)txManager.getTransaction();
    slaveDBResource=GlobalDBResource.valueOf(tx,slaveDBInfo,tableName);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
catch (  SystemException e) {
    throw new DBOperationException(e);
  }
  return slaveDBResource;
}
Program: 90375
Project: 90375
Buggy source:
/** 
 * 获取集群从库列表.
 * @param clazz 数据对象
 * @param slave 从库号
 */
List<IDBResource> getAllSlaveShardingDBResource(Class<?> clazz,EnumDBMasterSlave slave) throws SQLException, DBClusterException ;

Fixed version (ground truth):
/** 
 * 获取集群从库列表.
 * @param clazz 数据对象
 * @param slave 从库号
 */
List<IDBResource> getAllSlaveShardingDBResource(Class<?> clazz,EnumDBMasterSlave slave) throws SQLException, DBClusterException, SystemException ;
Program: 90376
Project: 90376
Buggy source:
/** 
 * get all master sharding info.
 * @param tableNum
 * @param clusterName
 * @param tableName
 * @return
 */
List<IDBResource> getAllMasterShardingDBResource(int tableNum,String clusterName,String tableName) throws SQLException, DBClusterException ;

Fixed version (ground truth):
/** 
 * get all master sharding info.
 * @param tableNum
 * @param clusterName
 * @param tableName
 * @return
 */
List<IDBResource> getAllMasterShardingDBResource(int tableNum,String clusterName,String tableName) throws SQLException, SystemException ;
Program: 90377
Project: 90377
Buggy source:
@Override public DataSource buildDataSource(String driverClass,String userName,String password,String url,Map<String,String> connectParam) throws LoadConfigException {
  BasicDataSource ds=new BasicDataSource();
  ds.setDriverClassName(driverClass);
  ds.setUsername(userName);
  ds.setPassword(password);
  ds.setUrl(url);
  ds.setValidationQuery("String_Node_Str");
  for (  Map.Entry<String,String> entry : connectParam.entrySet()) {
    try {
      BeansUtil.setProperty(ds,entry.getKey(),entry.getValue());
    }
 catch (    Exception e) {
      LOG.warn("String_Node_Str" + entry);
    }
  }
  return ds;
}

Fixed version (ground truth):
@Override public DataSource buildDataSource(String driverClass,String userName,String password,String url,Map<String,String> connectParam) throws LoadConfigException {
  BasicDataSource ds=new BasicDataSource();
  ds.setDriverClassName(driverClass);
  ds.setUsername(userName);
  ds.setPassword(password);
  ds.setUrl(url);
  ds.setValidationQuery("String_Node_Str");
  for (  Map.Entry<String,String> entry : connectParam.entrySet()) {
    try {
      setConnectionParam(ds,entry.getKey(),entry.getValue());
    }
 catch (    Exception e) {
      LOG.warn("String_Node_Str" + entry);
    }
  }
  return ds;
}
Program: 90378
Project: 90378
Buggy source:
@Override public DataSource buildDataSource(String driverClass,String userName,String password,String url,Map<String,String> connectParam) throws LoadConfigException {
  DruidDataSource ds=new DruidDataSource();
  ds.setDriverClassName(driverClass);
  ds.setUsername(userName);
  ds.setPassword(password);
  ds.setUrl(url);
  for (  Map.Entry<String,String> entry : connectParam.entrySet()) {
    if (entry.getKey().equals("String_Node_Str")) {
      try {
        BeansUtil.setProperty(ds,entry.getKey(),Class.forName(entry.getValue()).newInstance());
      }
 catch (      Exception e) {
        throw new LoadConfigException("String_Node_Str");
      }
    }
 else {
      try {
        BeansUtil.setProperty(ds,entry.getKey(),entry.getValue());
      }
 catch (      Exception e) {
        LOG.warn("String_Node_Str" + entry);
      }
    }
  }
  ds.setValidationQuery("String_Node_Str");
  return ds;
}

Fixed version (ground truth):
@Override public DataSource buildDataSource(String driverClass,String userName,String password,String url,Map<String,String> connectParam) throws LoadConfigException {
  DruidDataSource ds=new DruidDataSource();
  ds.setDriverClassName(driverClass);
  ds.setUsername(userName);
  ds.setPassword(password);
  ds.setUrl(url);
  for (  Map.Entry<String,String> entry : connectParam.entrySet()) {
    if (entry.getKey().equals("String_Node_Str")) {
      try {
        BeansUtil.setProperty(ds,entry.getKey(),Class.forName(entry.getValue()).newInstance());
      }
 catch (      Exception e) {
        throw new LoadConfigException("String_Node_Str");
      }
    }
 else {
      try {
        setConnectionParam(ds,entry.getKey(),entry.getValue());
      }
 catch (      Exception e) {
        LOG.warn("String_Node_Str" + entry);
      }
    }
  }
  ds.setValidationQuery("String_Node_Str");
  return ds;
}
Program: 90379
Project: 90379
Buggy source:
@Override public ShardingDBResource selectDBResourceFromSlave(String tableName,IShardingKey<?> value,EnumDBMasterSlave slaveNum) throws DBClusterException {
  RouteInfo routeInfo=null;
  try {
    String clusterName=value.getClusterName();
    IClusterRouter router=this.dbRouterC.find(clusterName);
    if (router == null) {
      throw new IllegalStateException("String_Node_Str" + clusterName);
    }
    routeInfo=router.select(slaveNum,tableName,value);
  }
 catch (  DBRouteException e) {
    throw new DBClusterException(e);
  }
  String clusterName=routeInfo.getClusterName();
  DBInfo dbInfo=routeInfo.getDbInfo();
  int tableIndex=routeInfo.getTableIndex();
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName + "String_Node_Str"+ value+ "String_Node_Str"+ tableName+ "String_Node_Str"+ slaveNum.getValue());
  }
  DBRegionInfo regionInfo=dbClusterInfo.getDbRegions().get(routeInfo.getRegionIndex());
  if (regionInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName + "String_Node_Str"+ value+ "String_Node_Str"+ tableName+ "String_Node_Str"+ slaveNum.getValue());
  }
  ShardingDBResource db;
  try {
    db=ShardingDBResource.valueOf(dbInfo,regionInfo,tableName,tableIndex);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
  return db;
}

Fixed version (ground truth):
@Override public ShardingDBResource selectDBResourceFromSlave(String tableName,IShardingKey<?> value,EnumDBMasterSlave slaveNum) throws DBClusterException {
  RouteInfo routeInfo=null;
  try {
    String clusterName=value.getClusterName();
    IClusterRouter router=this.dbRouterC.find(clusterName);
    if (router == null) {
      throw new IllegalStateException("String_Node_Str" + clusterName);
    }
    routeInfo=router.select(slaveNum,tableName,value);
  }
 catch (  DBRouteException e) {
    throw new DBClusterException(e);
  }
  String clusterName=routeInfo.getClusterName();
  DBInfo dbInfo=routeInfo.getDbInfo();
  int tableIndex=routeInfo.getTableIndex();
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName + "String_Node_Str"+ value+ "String_Node_Str"+ tableName+ "String_Node_Str"+ slaveNum.getValue());
  }
  DBRegionInfo regionInfo=dbClusterInfo.getDbRegions().get(routeInfo.getRegionIndex());
  if (regionInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName + "String_Node_Str"+ value+ "String_Node_Str"+ tableName+ "String_Node_Str"+ slaveNum.getValue());
  }
  ShardingDBResource db;
  try {
    ITransaction tx=(ITransaction)txManager.getTransaction();
    db=ShardingDBResource.valueOf(tx,dbInfo,regionInfo,tableName,tableIndex);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
catch (  SystemException e) {
    throw new DBOperationException(e);
  }
  return db;
}
Program: 90380
Project: 90380
Buggy source:
@Override public IDBResource getMasterGlobalDBResource(String clusterName,String tableName) throws DBClusterException {
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  DBInfo masterDBInfo=dbClusterInfo.getMasterGlobalDBInfo();
  if (masterDBInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  IDBResource masterDBResource;
  try {
    masterDBResource=GlobalDBResource.valueOf(masterDBInfo,tableName);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
  return masterDBResource;
}

Fixed version (ground truth):
@Override public IDBResource getMasterGlobalDBResource(String clusterName,String tableName) throws DBClusterException {
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  DBInfo masterDBInfo=dbClusterInfo.getMasterGlobalDBInfo();
  if (masterDBInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  IDBResource masterDBResource;
  try {
    ITransaction tx=(ITransaction)txManager.getTransaction();
    masterDBResource=GlobalDBResource.valueOf(tx,masterDBInfo,tableName);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
catch (  SystemException e) {
    throw new DBOperationException(e);
  }
  return masterDBResource;
}
Program: 90381
Project: 90381
Buggy source:
@Override public IDBResource getSlaveGlobalDBResource(String clusterName,String tableName,EnumDBMasterSlave masterSlave) throws DBClusterException {
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  List<DBInfo> slaveDbs=dbClusterInfo.getSlaveGlobalDBInfo();
  if (slaveDbs == null || slaveDbs.isEmpty()) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  DBInfo slaveDBInfo=null;
  if (EnumDBMasterSlave.AUTO == masterSlave) {
    slaveDBInfo=slaveDbs.get(r.nextInt(slaveDbs.size() - 1));
  }
 else {
    slaveDBInfo=slaveDbs.get(masterSlave.getValue());
  }
  IDBResource slaveDBResource;
  try {
    slaveDBResource=GlobalDBResource.valueOf(slaveDBInfo,tableName);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
  return slaveDBResource;
}

Fixed version (ground truth):
@Override public IDBResource getSlaveGlobalDBResource(String clusterName,String tableName,EnumDBMasterSlave masterSlave) throws DBClusterException {
  DBClusterInfo dbClusterInfo=this.dbClusterInfoC.find(clusterName);
  if (dbClusterInfo == null) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  List<DBInfo> slaveDbs=dbClusterInfo.getSlaveGlobalDBInfo();
  if (slaveDbs == null || slaveDbs.isEmpty()) {
    throw new DBClusterException("String_Node_Str" + clusterName);
  }
  DBInfo slaveDBInfo=null;
  if (EnumDBMasterSlave.AUTO == masterSlave) {
    slaveDBInfo=slaveDbs.get(r.nextInt(slaveDbs.size() - 1));
  }
 else {
    slaveDBInfo=slaveDbs.get(masterSlave.getValue());
  }
  IDBResource slaveDBResource;
  try {
    ITransaction tx=(ITransaction)txManager.getTransaction();
    slaveDBResource=GlobalDBResource.valueOf(tx,slaveDBInfo,tableName);
  }
 catch (  SQLException e) {
    throw new DBClusterException(e);
  }
catch (  SystemException e) {
    throw new DBOperationException(e);
  }
  return slaveDBResource;
}
Program: 90382
Project: 90382
Buggy source:
/** 
 * get all master sharding info.
 * @param tableNum
 * @param clusterName
 * @param tableName
 * @return
 * @throws SQLException
 */
public List<IDBResource> getAllMasterShardingDBResource(int tableNum,String clusterName,String tableName) throws SQLException {
  List<IDBResource> dbResources=new ArrayList<IDBResource>();
  if (tableNum == 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  IDBResource dbResource=null;
  DBClusterInfo dbClusterInfo=this.getDBClusterInfo(clusterName);
  for (  DBRegionInfo region : dbClusterInfo.getDbRegions()) {
    for (    DBInfo dbInfo : region.getMasterDBInfos()) {
      for (int tableIndex=0; tableIndex < tableNum; tableIndex++) {
        dbResource=ShardingDBResource.valueOf(dbInfo,region,tableName,tableIndex);
        dbResources.add(dbResource);
      }
    }
  }
  return dbResources;
}

Fixed version (ground truth):
/** 
 * get all master sharding info.
 * @param tableNum
 * @param clusterName
 * @param tableName
 * @return
 * @throws SQLException
 * @throws SystemException
 */
public List<IDBResource> getAllMasterShardingDBResource(int tableNum,String clusterName,String tableName) throws SQLException, SystemException {
  List<IDBResource> dbResources=new ArrayList<IDBResource>();
  if (tableNum == 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  ITransaction tx=(ITransaction)txManager.getTransaction();
  IDBResource dbResource=null;
  DBClusterInfo dbClusterInfo=this.getDBClusterInfo(clusterName);
  for (  DBRegionInfo region : dbClusterInfo.getDbRegions()) {
    for (    DBInfo dbInfo : region.getMasterDBInfos()) {
      for (int tableIndex=0; tableIndex < tableNum; tableIndex++) {
        dbResource=ShardingDBResource.valueOf(tx,dbInfo,region,tableName,tableIndex);
        dbResources.add(dbResource);
      }
    }
  }
  return dbResources;
}
Program: 90383
Project: 90383
Buggy source:
@Override public List<DBTable> getDBTableFromZk(){
  List<DBTable> tables=new ArrayList<DBTable>();
  try {
    ZooKeeper zkClient=this.curatorClient.getZookeeperClient().getZooKeeper();
    List<String> zkTableNodes=zkClient.getChildren(Const.ZK_SHARDINGINFO,false);
    byte[] tableData=null;
    for (    String zkTableNode : zkTableNodes) {
      tableData=zkClient.getData(Const.ZK_SHARDINGINFO + "String_Node_Str" + zkTableNode,false,null);
      tables.add(IOUtil.getObject(tableData,DBTable.class));
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  return tables;
}

Fixed version (ground truth):
@Override public List<DBTable> getDBTableFromZk(){
  List<DBTable> tables=new ArrayList<DBTable>();
  try {
    ZooKeeper zkClient=this.curatorClient.getZookeeperClient().getZooKeeper();
    List<String> zkTableNodes=zkClient.getChildren(Const.ZK_SHARDINGINFO,false);
    byte[] tableData=null;
    for (    String zkTableNode : zkTableNodes) {
      tableData=zkClient.getData(Const.ZK_SHARDINGINFO + "String_Node_Str" + zkTableNode,false,null);
      tables.add(IOUtil.getObjectByJava(tableData,DBTable.class));
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  return tables;
}
Program: 90384
Project: 90384
Buggy source:
/** 
 * 将表分片信息同步到zookeeper.
 */
private void _syncToZookeeper(List<DBTable> tables) throws Exception {
  try {
    ZooKeeper zkClient=this.curatorClient.getZookeeperClient().getZooKeeper();
    Stat stat=zkClient.exists(Const.ZK_SHARDINGINFO,false);
    if (stat == null) {
      zkClient.create(Const.ZK_SHARDINGINFO,new byte[0],ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
    }
    byte[] tableData=null;
    String tableName=null;
    for (    DBTable table : tables) {
      tableData=IOUtil.getBytes(table);
      tableName=table.getName();
      String zkTableNode=Const.ZK_SHARDINGINFO + "String_Node_Str" + tableName;
      stat=zkClient.exists(zkTableNode,false);
      if (stat == null) {
        zkClient.create(zkTableNode,tableData,ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
      }
 else {
        zkClient.setData(zkTableNode,tableData,-1);
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  LOG.info("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * 将表分片信息同步到zookeeper.
 */
private void _syncToZookeeper(List<DBTable> tables) throws Exception {
  try {
    ZooKeeper zkClient=this.curatorClient.getZookeeperClient().getZooKeeper();
    Stat stat=zkClient.exists(Const.ZK_SHARDINGINFO,false);
    if (stat == null) {
      zkClient.create(Const.ZK_SHARDINGINFO,new byte[0],ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
    }
    byte[] tableData=null;
    String tableName=null;
    for (    DBTable table : tables) {
      tableData=IOUtil.getBytesByJava(table);
      tableName=table.getName();
      String zkTableNode=Const.ZK_SHARDINGINFO + "String_Node_Str" + tableName;
      stat=zkClient.exists(zkTableNode,false);
      if (stat == null) {
        zkClient.create(zkTableNode,tableData,ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
      }
 else {
        zkClient.setData(zkTableNode,tableData,-1);
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  LOG.info("String_Node_Str");
}