nus-yam/ex-repair huggingface dataset:
Program: 38701
Project: 38701
Buggy source:
public void pause(){
  if (mTask != null) {
    mTask.cancel();
    mTask.waitDone();
    mDialog.dismiss();
    mDialog=null;
    mTask=null;
  }
}

Fixed version (ground truth):
public void pause(){
  stopTaskAndDismissDialog();
}
Program: 38702
Project: 38702
Buggy source:
public void prepareTextures(){
  if (mTileDecoder == null) {
    mTileDecoder=mThreadPool.submit(new TileDecoder());
  }
  if (mIsTextureFreed) {
    layoutTiles(mCenterX,mCenterY,mScale,mRotation);
    mIsTextureFreed=false;
    updateBackupTexture(mModel.getBackupImage());
  }
}

Fixed version (ground truth):
public void prepareTextures(){
  if (mTileDecoder == null) {
    mTileDecoder=mThreadPool.submit(new TileDecoder());
  }
  if (mIsTextureFreed) {
    layoutTiles(mCenterX,mCenterY,mScale,mRotation);
    mIsTextureFreed=false;
    updateBackupTexture(mModel != null ? mModel.getBackupImage() : null);
  }
}
Program: 38703
Project: 38703
Buggy source:
public void startAction(int action,int title,ProgressListener listener){
  ArrayList<Path> ids=mSelectionManager.getSelected(false);
  Utils.assertTrue(mDialog == null);
  Activity activity=(Activity)mActivity;
  mDialog=showProgressDialog(activity,title,ids.size());
  MediaOperation operation=new MediaOperation(action,ids,listener);
  mTask=mActivity.getThreadPool().submit(operation,null);
}

Fixed version (ground truth):
public void startAction(int action,int title,ProgressListener listener){
  ArrayList<Path> ids=mSelectionManager.getSelected(false);
  stopTaskAndDismissDialog();
  Activity activity=(Activity)mActivity;
  mDialog=showProgressDialog(activity,title,ids.size());
  MediaOperation operation=new MediaOperation(action,ids,listener);
  mTask=mActivity.getThreadPool().submit(operation,null);
}
Program: 38704
Project: 38704
Buggy source:
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
      if (mDialog != null) {
        mDialog.dismiss();
        mDialog=null;
        mTask=null;
      }
      if (message.obj != null) {
        ProgressListener listener=(ProgressListener)message.obj;
        listener.onProgressComplete(message.arg1);
      }
      mSelectionManager.leaveSelectionMode();
      break;
    }
case MSG_TASK_UPDATE:
{
    if (mDialog != null)     mDialog.setProgress(message.arg1);
    if (message.obj != null) {
      ProgressListener listener=(ProgressListener)message.obj;
      listener.onProgressUpdate(message.arg1);
    }
    break;
  }
case MSG_DO_SHARE:
{
  ((Activity)mActivity).startActivity((Intent)message.obj);
  break;
}
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
      stopTaskAndDismissDialog();
      if (message.obj != null) {
        ProgressListener listener=(ProgressListener)message.obj;
        listener.onProgressComplete(message.arg1);
      }
      mSelectionManager.leaveSelectionMode();
      break;
    }
case MSG_TASK_UPDATE:
{
    if (mDialog != null)     mDialog.setProgress(message.arg1);
    if (message.obj != null) {
      ProgressListener listener=(ProgressListener)message.obj;
      listener.onProgressUpdate(message.arg1);
    }
    break;
  }
case MSG_DO_SHARE:
{
  ((Activity)mActivity).startActivity((Intent)message.obj);
  break;
}
}
}
Program: 38705
Project: 38705
Buggy source:
public Void run(JobContext jc){
  int index=0;
  DataManager manager=mActivity.getDataManager();
  int result=EXECUTION_RESULT_SUCCESS;
  for (  Path id : mItems) {
    if (jc.isCancelled()) {
      result=EXECUTION_RESULT_CANCEL;
      break;
    }
    try {
      if (!execute(manager,jc,mOperation,id))       result=EXECUTION_RESULT_FAIL;
    }
 catch (    Throwable th) {
      Log.e(TAG,"String_Node_Str" + mOperation + "String_Node_Str"+ id,th);
    }
    onProgressUpdate(index++,mListener);
  }
  onProgressComplete(result,mListener);
  return null;
}

Fixed version (ground truth):
public Void run(JobContext jc){
  int index=0;
  DataManager manager=mActivity.getDataManager();
  int result=EXECUTION_RESULT_SUCCESS;
  try {
    for (    Path id : mItems) {
      if (jc.isCancelled()) {
        result=EXECUTION_RESULT_CANCEL;
        break;
      }
      if (!execute(manager,jc,mOperation,id)) {
        result=EXECUTION_RESULT_FAIL;
      }
      onProgressUpdate(index++,mListener);
    }
  }
 catch (  Throwable th) {
    Log.e(TAG,"String_Node_Str" + mOperation + "String_Node_Str"+ th);
  }
 finally {
    onProgressComplete(result,mListener);
  }
  return null;
}
Program: 38706
Project: 38706
Buggy source:
public MenuExecutor(GalleryActivity activity,SelectionManager selectionManager){
  mActivity=Utils.checkNotNull(activity);
  mSelectionManager=Utils.checkNotNull(selectionManager);
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
          if (mDialog != null) {
            mDialog.dismiss();
            mDialog=null;
            mTask=null;
          }
          if (message.obj != null) {
            ProgressListener listener=(ProgressListener)message.obj;
            listener.onProgressComplete(message.arg1);
          }
          mSelectionManager.leaveSelectionMode();
          break;
        }
case MSG_TASK_UPDATE:
{
        if (mDialog != null)         mDialog.setProgress(message.arg1);
        if (message.obj != null) {
          ProgressListener listener=(ProgressListener)message.obj;
          listener.onProgressUpdate(message.arg1);
        }
        break;
      }
case MSG_DO_SHARE:
{
      ((Activity)mActivity).startActivity((Intent)message.obj);
      break;
    }
}
}
}
;
}

Fixed version (ground truth):
public MenuExecutor(GalleryActivity activity,SelectionManager selectionManager){
  mActivity=Utils.checkNotNull(activity);
  mSelectionManager=Utils.checkNotNull(selectionManager);
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
          stopTaskAndDismissDialog();
          if (message.obj != null) {
            ProgressListener listener=(ProgressListener)message.obj;
            listener.onProgressComplete(message.arg1);
          }
          mSelectionManager.leaveSelectionMode();
          break;
        }
case MSG_TASK_UPDATE:
{
        if (mDialog != null)         mDialog.setProgress(message.arg1);
        if (message.obj != null) {
          ProgressListener listener=(ProgressListener)message.obj;
          listener.onProgressUpdate(message.arg1);
        }
        break;
      }
case MSG_DO_SHARE:
{
      ((Activity)mActivity).startActivity((Intent)message.obj);
      break;
    }
}
}
}
;
}
Program: 38708
Project: 38708
Buggy source:
public void pause(){
  if (mTask != null) {
    mTask.cancel();
    mTask.waitDone();
    mDialog.dismiss();
    mDialog=null;
    mTask=null;
  }
}

Fixed version (ground truth):
public void pause(){
  stopTaskAndDismissDialog();
}
Program: 38709
Project: 38709
Buggy source:
public void prepareTextures(){
  if (mTileDecoder == null) {
    mTileDecoder=mThreadPool.submit(new TileDecoder());
  }
  if (mIsTextureFreed) {
    layoutTiles(mCenterX,mCenterY,mScale,mRotation);
    mIsTextureFreed=false;
    updateBackupTexture(mModel.getBackupImage());
  }
}

Fixed version (ground truth):
public void prepareTextures(){
  if (mTileDecoder == null) {
    mTileDecoder=mThreadPool.submit(new TileDecoder());
  }
  if (mIsTextureFreed) {
    layoutTiles(mCenterX,mCenterY,mScale,mRotation);
    mIsTextureFreed=false;
    updateBackupTexture(mModel != null ? mModel.getBackupImage() : null);
  }
}
Program: 38710
Project: 38710
Buggy source:
@Override public void onCreate(Bundle data,Bundle restoreState){
  initializeViews();
  initializeData(data);
  mGetContent=data.getBoolean(Gallery.KEY_GET_CONTENT,false);
  mGetAlbum=data.getBoolean(Gallery.KEY_GET_ALBUM,false);
  mTitle=data.getString(AlbumSetPage.KEY_SET_TITLE);
  mSubtitle=data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
  mEyePosition=new EyePosition(mActivity.getAndroidContext(),this);
  mDetailsSource=new MyDetailsSource();
  mActivity.getGalleryActionBar().setSelectedTab(data.getInt(AlbumSetPage.KEY_SELECTED_TAB_TYPE,FilterUtils.CLUSTER_BY_ALBUM));
  startTransition();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle data,Bundle restoreState){
  initializeViews();
  initializeData(data);
  mGetContent=data.getBoolean(Gallery.KEY_GET_CONTENT,false);
  mGetAlbum=data.getBoolean(Gallery.KEY_GET_ALBUM,false);
  mTitle=data.getString(AlbumSetPage.KEY_SET_TITLE);
  mSubtitle=data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
  mEyePosition=new EyePosition(mActivity.getAndroidContext(),this);
  mDetailsSource=new MyDetailsSource();
  GalleryActionBar actionBar=mActivity.getGalleryActionBar();
  if (actionBar != null) {
    actionBar.setSelectedTab(data.getInt(AlbumSetPage.KEY_SELECTED_TAB_TYPE,FilterUtils.CLUSTER_BY_ALBUM));
  }
  startTransition();
}
Program: 38711
Project: 38711
Buggy source:
public void onFutureDone(Future<Bitmap> future){
  mFuture=future;
  mMainHandler.sendMessage(mMainHandler.obtainMessage(MSG_RUN_OBJECT,this));
}

Fixed version (ground truth):
@Override public void onFutureDone(Future<Bitmap> future){
  mFuture=future;
  mMainHandler.sendMessage(mMainHandler.obtainMessage(MSG_RUN_OBJECT,this));
}
Program: 38712
Project: 38712
Buggy source:
private void updateScreenNail(long version,Future<Bitmap> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.screenNailTask == null) {
    Bitmap screenNail=future.get();
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  entry.screenNail=future.get();
  if (entry.screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,false);
    }
    for (int i=-1; i <= 1; ++i) {
      if (version == getVersion(mCurrentIndex + i)) {
        if (i == 0)         updateTileProvider(entry);
        mPhotoView.notifyImageInvalidated(i);
      }
    }
  }
  updateImageRequests();
}

Fixed version (ground truth):
private void updateScreenNail(long version,Future<Bitmap> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.screenNailTask != future) {
    Bitmap screenNail=future.get();
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  entry.screenNail=future.get();
  if (entry.screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,false);
    }
    for (int i=-1; i <= 1; ++i) {
      if (version == getVersion(mCurrentIndex + i)) {
        if (i == 0)         updateTileProvider(entry);
        mPhotoView.notifyImageInvalidated(i);
      }
    }
  }
  updateImageRequests();
}
Program: 38713
Project: 38713
Buggy source:
private void updateFullImage(long version,Future<BitmapRegionDecoder> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.fullImageTask == null) {
    BitmapRegionDecoder fullImage=future.get();
    if (fullImage != null)     fullImage.recycle();
    return;
  }
  entry.fullImageTask=null;
  entry.fullImage=future.get();
  if (entry.fullImage != null) {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,true);
    }
    if (version == getVersion(mCurrentIndex)) {
      updateTileProvider(entry);
      mPhotoView.notifyImageInvalidated(0);
    }
  }
  updateImageRequests();
}

Fixed version (ground truth):
private void updateFullImage(long version,Future<BitmapRegionDecoder> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.fullImageTask != future) {
    BitmapRegionDecoder fullImage=future.get();
    if (fullImage != null)     fullImage.recycle();
    return;
  }
  entry.fullImageTask=null;
  entry.fullImage=future.get();
  if (entry.fullImage != null) {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,true);
    }
    if (version == getVersion(mCurrentIndex)) {
      updateTileProvider(entry);
      mPhotoView.notifyImageInvalidated(0);
    }
  }
  updateImageRequests();
}
Program: 38714
Project: 38714
Buggy source:
@Override public void onCreate(Bundle data,Bundle restoreState){
  initializeViews();
  initializeData(data);
  mGetContent=data.getBoolean(Gallery.KEY_GET_CONTENT,false);
  mGetAlbum=data.getBoolean(Gallery.KEY_GET_ALBUM,false);
  mTitle=data.getString(AlbumSetPage.KEY_SET_TITLE);
  mSubtitle=data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
  mEyePosition=new EyePosition(mActivity.getAndroidContext(),this);
  mDetailsSource=new MyDetailsSource();
  mActivity.getGalleryActionBar().setSelectedTab(data.getInt(AlbumSetPage.KEY_SELECTED_TAB_TYPE,FilterUtils.CLUSTER_BY_ALBUM));
  startTransition();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle data,Bundle restoreState){
  initializeViews();
  initializeData(data);
  mGetContent=data.getBoolean(Gallery.KEY_GET_CONTENT,false);
  mGetAlbum=data.getBoolean(Gallery.KEY_GET_ALBUM,false);
  mTitle=data.getString(AlbumSetPage.KEY_SET_TITLE);
  mSubtitle=data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
  mEyePosition=new EyePosition(mActivity.getAndroidContext(),this);
  mDetailsSource=new MyDetailsSource();
  GalleryActionBar actionBar=mActivity.getGalleryActionBar();
  if (actionBar != null) {
    actionBar.setSelectedTab(data.getInt(AlbumSetPage.KEY_SELECTED_TAB_TYPE,FilterUtils.CLUSTER_BY_ALBUM));
  }
  startTransition();
}
Program: 38715
Project: 38715
Buggy source:
void resume(){
  Activity activity=(Activity)mActivity;
  ActionBar actionBar=activity.getActionBar();
  if (actionBar != null) {
    if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
      actionBar.hide();
    }
 else {
      actionBar.show();
    }
    int stateCount=mActivity.getStateManager().getStateCount();
    actionBar.setDisplayOptions(stateCount == 1 ? 0 : ActionBar.DISPLAY_HOME_AS_UP,ActionBar.DISPLAY_HOME_AS_UP);
    actionBar.setHomeButtonEnabled(true);
  }
  activity.invalidateOptionsMenu();
  if ((mFlags & FLAG_HIDE_STATUS_BAR) != 0) {
    WindowManager.LayoutParams params=((Activity)mActivity).getWindow().getAttributes();
    params.systemUiVisibility=View.STATUS_BAR_HIDDEN;
    ((Activity)mActivity).getWindow().setAttributes(params);
  }
 else {
    WindowManager.LayoutParams params=((Activity)mActivity).getWindow().getAttributes();
    params.systemUiVisibility=View.STATUS_BAR_VISIBLE;
    ((Activity)mActivity).getWindow().setAttributes(params);
  }
  ResultEntry entry=mReceivedResults;
  if (entry != null) {
    mReceivedResults=null;
    onStateResult(entry.requestCode,entry.resultCode,entry.resultData);
  }
  onResume();
}

Fixed version (ground truth):
void resume(){
  Activity activity=(Activity)mActivity;
  ActionBar actionBar=activity.getActionBar();
  if (actionBar != null) {
    if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
      actionBar.hide();
    }
 else {
      actionBar.show();
    }
    int stateCount=mActivity.getStateManager().getStateCount();
    actionBar.setDisplayOptions(stateCount == 1 ? 0 : ActionBar.DISPLAY_HOME_AS_UP,ActionBar.DISPLAY_HOME_AS_UP);
    actionBar.setHomeButtonEnabled(true);
  }
  activity.invalidateOptionsMenu();
  if ((mFlags & FLAG_HIDE_STATUS_BAR) != 0) {
    WindowManager.LayoutParams params=((Activity)mActivity).getWindow().getAttributes();
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_LOW_PROFILE;
    ((Activity)mActivity).getWindow().setAttributes(params);
  }
 else {
    WindowManager.LayoutParams params=((Activity)mActivity).getWindow().getAttributes();
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_VISIBLE;
    ((Activity)mActivity).getWindow().setAttributes(params);
  }
  ResultEntry entry=mReceivedResults;
  if (entry != null) {
    mReceivedResults=null;
    onStateResult(entry.requestCode,entry.resultCode,entry.resultData);
  }
  onResume();
}
Program: 38716
Project: 38716
Buggy source:
protected boolean onCreateActionBar(Menu menu){
  return false;
}

Fixed version (ground truth):
protected boolean onCreateActionBar(Menu menu){
  return true;
}
Program: 38717
Project: 38717
Buggy source:
@Override public void onCreate(Bundle data,Bundle restoreState){
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
      Utils.assertTrue(message.what == MSG_GOTO_MANAGE_CACHE_PAGE);
      Bundle data=new Bundle();
      String mediaPath=mActivity.getDataManager().getTopSetPath(DataManager.INCLUDE_ALL);
      data.putString(AlbumSetPage.KEY_MEDIA_PATH,mediaPath);
      mActivity.getStateManager().startState(ManageCachePage.class,data);
    }
  }
;
  initializeViews();
  initializeData(data);
  mGetContent=data.getBoolean(Gallery.KEY_GET_CONTENT,false);
  mGetAlbum=data.getBoolean(Gallery.KEY_GET_ALBUM,false);
  mTitle=data.getString(AlbumSetPage.KEY_SET_TITLE);
  mSubtitle=data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
  mEyePosition=new EyePosition(mActivity.getAndroidContext(),this);
  mDetailsSource=new MyDetailsSource();
  startTransition();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle data,Bundle restoreState){
  initializeViews();
  initializeData(data);
  mGetContent=data.getBoolean(Gallery.KEY_GET_CONTENT,false);
  mGetAlbum=data.getBoolean(Gallery.KEY_GET_ALBUM,false);
  mTitle=data.getString(AlbumSetPage.KEY_SET_TITLE);
  mSubtitle=data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
  mEyePosition=new EyePosition(mActivity.getAndroidContext(),this);
  mDetailsSource=new MyDetailsSource();
  mActivity.getGalleryActionBar().setSelectedTab(data.getInt(AlbumSetPage.KEY_SELECTED_TAB_TYPE,FilterUtils.CLUSTER_BY_ALBUM));
  startTransition();
}
Program: 38718
Project: 38718
Buggy source:
@Override protected boolean onItemSelected(MenuItem item){
  Activity activity=(Activity)mActivity;
switch (item.getItemId()) {
case R.id.action_cancel:
    activity.setResult(Activity.RESULT_CANCELED);
  activity.finish();
return true;
case R.id.action_select:
mSelectionManager.setAutoLeaveSelectionMode(false);
mSelectionManager.enterSelectionMode();
return true;
case R.id.action_details:
if (mAlbumSetDataAdapter.size() != 0) {
if (mShowDetails) {
hideDetails();
}
 else {
showDetails();
}
}
 else {
Toast.makeText(activity,activity.getText(R.string.no_albums_alert),Toast.LENGTH_SHORT).show();
}
return true;
case R.id.action_camera:
{
Intent intent=new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
return true;
}
case R.id.action_manage_offline:
{
mHandler.sendEmptyMessage(MSG_GOTO_MANAGE_CACHE_PAGE);
return true;
}
case R.id.action_sync_picasa_albums:
{
PicasaSource.requestSync(activity);
return true;
}
case R.id.action_settings:
{
activity.startActivity(new Intent(activity,GallerySettings.class));
return true;
}
default :
return false;
}
}

Fixed version (ground truth):
@Override protected boolean onItemSelected(MenuItem item){
  Activity activity=(Activity)mActivity;
switch (item.getItemId()) {
case R.id.action_cancel:
    activity.setResult(Activity.RESULT_CANCELED);
  activity.finish();
return true;
case R.id.action_select:
mSelectionManager.setAutoLeaveSelectionMode(false);
mSelectionManager.enterSelectionMode();
return true;
case R.id.action_details:
if (mAlbumSetDataAdapter.size() != 0) {
if (mShowDetails) {
hideDetails();
}
 else {
showDetails();
}
}
 else {
Toast.makeText(activity,activity.getText(R.string.no_albums_alert),Toast.LENGTH_SHORT).show();
}
return true;
case R.id.action_camera:
{
Intent intent=new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
return true;
}
case R.id.action_manage_offline:
{
Bundle data=new Bundle();
String mediaPath=mActivity.getDataManager().getTopSetPath(DataManager.INCLUDE_ALL);
data.putString(AlbumSetPage.KEY_MEDIA_PATH,mediaPath);
mActivity.getStateManager().startState(ManageCachePage.class,data);
return true;
}
case R.id.action_sync_picasa_albums:
{
PicasaSource.requestSync(activity);
return true;
}
case R.id.action_settings:
{
activity.startActivity(new Intent(activity,GallerySettings.class));
return true;
}
default :
return false;
}
}
Program: 38719
Project: 38719
Buggy source:
public void doCluster(int clusterType){
  String basePath=mMediaSet.getPath().toString();
  String newPath=FilterUtils.switchClusterPath(basePath,clusterType);
  Bundle data=new Bundle(getData());
  data.putString(AlbumSetPage.KEY_MEDIA_PATH,newPath);
  mAlbumSetView.savePositions(PositionRepository.getInstance(mActivity));
  mActivity.getStateManager().switchState(this,AlbumSetPage.class,data);
}

Fixed version (ground truth):
public void doCluster(int clusterType){
  String basePath=mMediaSet.getPath().toString();
  String newPath=FilterUtils.switchClusterPath(basePath,clusterType);
  Bundle data=new Bundle(getData());
  data.putString(AlbumSetPage.KEY_MEDIA_PATH,newPath);
  data.putInt(KEY_SELECTED_TAB_TYPE,clusterType);
  mAlbumSetView.savePositions(PositionRepository.getInstance(mActivity));
  mActivity.getStateManager().switchState(this,AlbumSetPage.class,data);
}
Program: 38720
Project: 38720
Buggy source:
public int getIndex(){
  return mIndex;
}

Fixed version (ground truth):
@Override public int getIndex(){
  return mIndex;
}
Program: 38721
Project: 38721
Buggy source:
public MediaDetails getDetails(){
  return mModel.getCurrentMediaItem().getDetails();
}

Fixed version (ground truth):
@Override public MediaDetails getDetails(){
  return mModel.getCurrentMediaItem().getDetails();
}
Program: 38722
Project: 38722
Buggy source:
public int findIndex(int indexHint){
  mIndex=indexHint;
  return indexHint;
}

Fixed version (ground truth):
@Override public int findIndex(int indexHint){
  mIndex=indexHint;
  return indexHint;
}
Program: 38723
Project: 38723
Buggy source:
public int size(){
  return mMediaSet != null ? mMediaSet.getMediaItemCount() : 1;
}

Fixed version (ground truth):
@Override public int size(){
  return mMediaSet != null ? mMediaSet.getMediaItemCount() : 1;
}
Program: 38724
Project: 38724
Buggy source:
private void saveData(SQLiteDatabase db,int oldVersion,ArrayList<Entry> data){
  if (oldVersion <= 2) {
    Cursor cursor=db.query("String_Node_Str",new String[]{FIELD_APPWIDGET_ID,FIELD_PHOTO_BLOB},null,null,null,null,null);
    if (cursor == null)     return;
    try {
      while (cursor.moveToNext()) {
        Entry entry=new Entry();
        entry.type=TYPE_SINGLE_PHOTO;
        entry.widgetId=cursor.getInt(0);
        entry.imageData=cursor.getBlob(1);
        data.add(entry);
      }
    }
  finally {
      cursor.close();
    }
  }
 else   if (oldVersion == 3) {
    Utils.debug("String_Node_Str",oldVersion);
    Cursor cursor=db.query("String_Node_Str",new String[]{FIELD_APPWIDGET_ID,FIELD_PHOTO_BLOB,FIELD_IMAGE_URI},null,null,null,null,null);
    if (cursor == null)     return;
    try {
      while (cursor.moveToNext()) {
        Entry entry=new Entry();
        entry.type=TYPE_SINGLE_PHOTO;
        entry.widgetId=cursor.getInt(0);
        entry.imageData=cursor.getBlob(1);
        entry.imageUri=cursor.getString(2);
        Utils.debug("String_Node_Str",entry.widgetId,entry.imageUri);
        data.add(entry);
      }
    }
  finally {
      cursor.close();
    }
  }
}

Fixed version (ground truth):
private void saveData(SQLiteDatabase db,int oldVersion,ArrayList<Entry> data){
  if (oldVersion <= 2) {
    Cursor cursor=db.query("String_Node_Str",new String[]{FIELD_APPWIDGET_ID,FIELD_PHOTO_BLOB},null,null,null,null,null);
    if (cursor == null)     return;
    try {
      while (cursor.moveToNext()) {
        Entry entry=new Entry();
        entry.type=TYPE_SINGLE_PHOTO;
        entry.widgetId=cursor.getInt(0);
        entry.imageData=cursor.getBlob(1);
        data.add(entry);
      }
    }
  finally {
      cursor.close();
    }
  }
 else   if (oldVersion == 3) {
    Cursor cursor=db.query("String_Node_Str",new String[]{FIELD_APPWIDGET_ID,FIELD_PHOTO_BLOB,FIELD_IMAGE_URI},null,null,null,null,null);
    if (cursor == null)     return;
    try {
      while (cursor.moveToNext()) {
        Entry entry=new Entry();
        entry.type=TYPE_SINGLE_PHOTO;
        entry.widgetId=cursor.getInt(0);
        entry.imageData=cursor.getBlob(1);
        entry.imageUri=cursor.getString(2);
        data.add(entry);
      }
    }
  finally {
      cursor.close();
    }
  }
}
Program: 38725
Project: 38725
Buggy source:
boolean decode(){
  int tileLength=(TILE_SIZE + 2 * TILE_BORDER);
  int borderLength=TILE_BORDER << mTileLevel;
  try {
    mDecodedTile=mModel.getTile(mTileLevel,mX - borderLength,mY - borderLength,tileLength);
    return mDecodedTile != null;
  }
 catch (  Throwable t) {
    Log.w(TAG,"String_Node_Str",t);
    return false;
  }
}

Fixed version (ground truth):
boolean decode(){
  int tileLength=(TILE_SIZE + 2 * TILE_BORDER);
  int borderLength=TILE_BORDER << mTileLevel;
  try {
    mDecodedTile=DecodeUtils.ensureGLCompatibleBitmap(mModel.getTile(mTileLevel,mX - borderLength,mY - borderLength,tileLength));
    return mDecodedTile != null;
  }
 catch (  Throwable t) {
    Log.w(TAG,"String_Node_Str",t);
    return false;
  }
}
Program: 38726
Project: 38726
Buggy source:
boolean decode(){
  int tileLength=(TILE_SIZE + 2 * TILE_BORDER);
  int borderLength=TILE_BORDER << mTileLevel;
  try {
    mDecodedTile=mModel.getTile(mTileLevel,mX - borderLength,mY - borderLength,tileLength);
    return mDecodedTile != null;
  }
 catch (  Throwable t) {
    Log.w(TAG,"String_Node_Str",t);
    return false;
  }
}

Fixed version (ground truth):
boolean decode(){
  int tileLength=(TILE_SIZE + 2 * TILE_BORDER);
  int borderLength=TILE_BORDER << mTileLevel;
  try {
    mDecodedTile=DecodeUtils.ensureGLCompatibleBitmap(mModel.getTile(mTileLevel,mX - borderLength,mY - borderLength,tileLength));
    return mDecodedTile != null;
  }
 catch (  Throwable t) {
    Log.w(TAG,"String_Node_Str",t);
    return false;
  }
}
Program: 38727
Project: 38727
Buggy source:
private Database createDatabaseIfNotExists(String dbName){
  try {
    final List<Database> dbList=documentDbFactory.getDocumentClient().queryDatabases(new SqlQuerySpec("String_Node_Str",new SqlParameterCollection(new SqlParameter("String_Node_Str",dbName))),null).getQueryIterable().toList();
    if (!dbList.isEmpty()) {
      return dbList.get(0);
    }
 else {
      final Database db=new Database();
      db.setId(dbName);
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("String_Node_Str",dbName);
      }
      final Resource resource=documentDbFactory.getDocumentClient().createDatabase(db,null).getResource();
      if (resource instanceof Database) {
        return (Database)resource;
      }
 else {
        LOGGER.error("String_Node_Str" + resource.getSelfLink());
        throw new DatabaseCreationException("String_Node_Str" + resource.getSelfLink());
      }
    }
  }
 catch (  DocumentClientException ex) {
    throw new DocumentDBAccessException("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private Database createDatabaseIfNotExists(String dbName){
  try {
    final List<Database> dbList=documentDbFactory.getDocumentClient().queryDatabases(new SqlQuerySpec("String_Node_Str",new SqlParameterCollection(new SqlParameter("String_Node_Str",dbName))),null).getQueryIterable().toList();
    if (!dbList.isEmpty()) {
      return dbList.get(0);
    }
 else {
      final Database db=new Database();
      db.setId(dbName);
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("String_Node_Str",dbName);
      }
      final Resource resource=documentDbFactory.getDocumentClient().createDatabase(db,null).getResource();
      if (resource instanceof Database) {
        return (Database)resource;
      }
 else {
        final String errorMessage=MessageFormat.format("String_Node_Str",dbName,resource.getSelfLink());
        LOGGER.error(errorMessage);
        throw new DatabaseCreationException(errorMessage);
      }
    }
  }
 catch (  DocumentClientException ex) {
    throw new DocumentDBAccessException("String_Node_Str",ex);
  }
}
Program: 38728
Project: 38728
Buggy source:
public DocumentDbQueryCreator(PartTree tree,DocumentDbParameterAccessor accessor,MappingContext<?,DocumentDbPersistentProperty> mappingContext){
  super(tree,accessor);
  this.accessor=accessor;
  this.mappingContext=mappingContext;
}

Fixed version (ground truth):
public DocumentDbQueryCreator(PartTree tree,DocumentDbParameterAccessor accessor,MappingContext<?,DocumentDbPersistentProperty> mappingContext){
  super(tree,accessor);
  this.mappingContext=mappingContext;
}
Program: 38729
Project: 38729
Buggy source:
public static ZooKeeperLocal provideZooKeeperLocal(){
  Properties zkProperties=new Properties();
  zkProperties.put("String_Node_Str",(String)String.valueOf(zookeeperPort));
  zkProperties.put("String_Node_Str",(String)"String_Node_Str");
  zkProperties.put("String_Node_Str",(String)"String_Node_Str");
  try {
    FileUtils.deleteDirectory(new File((String)zkProperties.get("String_Node_Str")));
    zookeeper=new ZooKeeperLocal(zkProperties);
    zookeeper.start();
    return zookeeper;
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
public static ZooKeeperLocal provideZooKeeperLocal(){
  final Properties zkProperties=new Properties();
  zkProperties.put("String_Node_Str",String.valueOf(zookeeperPort));
  zkProperties.put("String_Node_Str","String_Node_Str");
  zkProperties.put("String_Node_Str","String_Node_Str");
  try {
    FileUtils.deleteDirectory(new File((String)zkProperties.get("String_Node_Str")));
    zookeeper=new ZooKeeperLocal(zkProperties);
    zookeeper.start();
    return zookeeper;
  }
 catch (  final IOException e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 38730
Project: 38730
Buggy source:
public static void setZookeeper(ZooKeeperLocal zookeeper){
  KafkaServer.zookeeper=zookeeper;
}

Fixed version (ground truth):
public static void setZookeeper(final ZooKeeperLocal zookeeper){
  KafkaServer.zookeeper=zookeeper;
}
Program: 38731
Project: 38731
Buggy source:
public static void setKafkaLocal(KafkaLocal kafkaLocal){
  KafkaServer.kafkaLocal=kafkaLocal;
}

Fixed version (ground truth):
public static void setKafkaLocal(final KafkaLocal kafkaLocal){
  KafkaServer.kafkaLocal=kafkaLocal;
}
Program: 38732
Project: 38732
Buggy source:
/** 
 * Starts a local Kafka Server (inlcudes zookeper and kafka) , if it has not been started already.
 * @return The port of the zookeeper server.
 */
public static Integer startKafkaServer(String topicName){
  if (null == kafkaLocal) {
    kafkaLocal=provideKafkaServer();
    createTopicWithThreePartitions(topicName);
  }
  return zookeeperPort;
}

Fixed version (ground truth):
/** 
 * Starts a local Kafka Server (inlcudes zookeper and kafka) , if it has not been started already. FIXME: currently, application-test config assumes port 32000; if server starts on other port, tests will fail!
 * @return The port of the zookeeper server.
 */
public static Integer startKafkaServer(final String topicName){
  if (null == kafkaLocal) {
    kafkaLocal=provideKafkaServer();
    createTopicWithThreePartitions(topicName);
  }
  return zookeeperPort;
}
Program: 38733
Project: 38733
Buggy source:
public static void setZookeeperPort(Integer zookeeperPort){
  KafkaServer.zookeeperPort=zookeeperPort;
}

Fixed version (ground truth):
public static void setZookeeperPort(final Integer zookeeperPort){
  KafkaServer.zookeeperPort=zookeeperPort;
}
Program: 38734
Project: 38734
Buggy source:
public static void createTopicWithThreePartitions(String topicName){
  Integer sessionTimeoutMs=10000;
  Integer connectionTimeoutMs=10000;
  ZkConnection zkConnection=new ZkConnection("String_Node_Str" + String.valueOf(zookeeperPort),sessionTimeoutMs);
  ZkClient zkClient=new ZkClient(zkConnection,connectionTimeoutMs,ZKStringSerializer$.MODULE$);
  ZkUtils zkUtils=new ZkUtils(zkClient,zkConnection,false);
  Integer numPartitions=3;
  Integer replicationFactor=1;
  Properties topicConfig=new Properties();
  try {
    LOG.info("String_Node_Str" + topicName);
    AdminUtils.deleteTopic(zkUtils,topicName);
  }
 catch (  UnknownTopicOrPartitionException e) {
    LOG.info("String_Node_Str");
  }
  LOG.info("String_Node_Str" + topicName);
  AdminUtils.createTopic(zkUtils,topicName,numPartitions,replicationFactor,topicConfig,null);
  zkClient.close();
}

Fixed version (ground truth):
public static void createTopicWithThreePartitions(final String topicName){
  final Integer sessionTimeoutMs=10000;
  final Integer connectionTimeoutMs=10000;
  final ZkConnection zkConnection=new ZkConnection("String_Node_Str" + String.valueOf(zookeeperPort),sessionTimeoutMs);
  final ZkClient zkClient=new ZkClient(zkConnection,connectionTimeoutMs,ZKStringSerializer$.MODULE$);
  final ZkUtils zkUtils=new ZkUtils(zkClient,zkConnection,false);
  final Integer numPartitions=3;
  final Integer replicationFactor=1;
  final Properties topicConfig=new Properties();
  try {
    LOG.info("String_Node_Str" + topicName);
    AdminUtils.deleteTopic(zkUtils,topicName);
  }
 catch (  final UnknownTopicOrPartitionException e) {
    LOG.info("String_Node_Str");
  }
  LOG.info("String_Node_Str" + topicName);
  AdminUtils.createTopic(zkUtils,topicName,numPartitions,replicationFactor,topicConfig,null);
  zkClient.close();
}
Program: 38735
Project: 38735
Buggy source:
public static KafkaLocal provideKafkaServer(){
  Properties kafkaProperties=new Properties();
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str" + String.valueOf(zookeeperPort));
  kafkaProperties.put("String_Node_Str",(String)String.valueOf(kafkaPort));
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  kafkaProperties.put("String_Node_Str",(String)"String_Node_Str");
  try {
    FileUtils.deleteDirectory(new File((String)kafkaProperties.get("String_Node_Str")));
    ZooKeeperLocal zooKeeperLocal=provideZooKeeperLocal();
    KafkaLocal kafka=new KafkaLocal(kafkaProperties,zooKeeperLocal);
    kafka.start();
    Thread.sleep(2000);
    return ((KafkaLocal)(kafka));
  }
 catch (  IOException|InterruptedException e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
public static KafkaLocal provideKafkaServer(){
  final Properties kafkaProperties=new Properties();
  kafkaProperties.put("String_Node_Str","String_Node_Str" + String.valueOf(zookeeperPort));
  kafkaProperties.put("String_Node_Str",String.valueOf(kafkaPort));
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  kafkaProperties.put("String_Node_Str","String_Node_Str");
  try {
    FileUtils.deleteDirectory(new File((String)kafkaProperties.get("String_Node_Str")));
    final ZooKeeperLocal zooKeeperLocal=provideZooKeeperLocal();
    final KafkaLocal kafka=new KafkaLocal(kafkaProperties,zooKeeperLocal);
    kafka.start();
    Thread.sleep(2000);
    return ((kafka));
  }
 catch (  IOException|InterruptedException e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 38736
Project: 38736
Buggy source:
public static void setKafkaPort(Integer kafkaPort){
  KafkaServer.kafkaPort=kafkaPort;
}

Fixed version (ground truth):
public static void setKafkaPort(final Integer kafkaPort){
  KafkaServer.kafkaPort=kafkaPort;
}
Program: 38737
Project: 38737
Buggy source:
public static ProductEntity of(final Product product){
}

Fixed version (ground truth):
public static ProductEntity of(final Product product){
  ProductEntity productEntity=new ProductEntity();
  productEntity.name=product.getName();
  productEntity.vendor=product.getVendor();
  productEntity.price=product.getPrice();
  productEntity.description=product.getDescription();
  productEntity.productNumber=product.getProductNumber();
  productEntity.image=product.getImage();
  productEntity.version=product.getVersion();
  return productEntity;
}
Program: 38738
Project: 38738
Buggy source:
@RequestMapping(value="String_Node_Str",method=RequestMethod.PUT) public Product addProduct(final Product product){
}

Fixed version (ground truth):
@RequestMapping(value="String_Node_Str",method=RequestMethod.PUT) public Product addProduct(final Product product){
  return null;
}
Program: 38739
Project: 38739
Buggy source:
@Override public CompletionStage<Response<ByteString>> getTemplate(final RouteMatch match,final RequestContext context){
  return CompletableFuture.completedFuture(Response.of(Status.OK,ByteString.encodeUtf8(SERVICE_RESPONSE)));
}

Fixed version (ground truth):
@Override public CompletionStage<Response<ByteString>> getTemplate(final RouteMatch match,final RequestContext context){
  return CompletableFuture.completedFuture(Response.of(status,ByteString.encodeUtf8(responseBody)));
}
Program: 38740
Project: 38740
Buggy source:
private RuleRouter<Match> aRouter(){
  final Rule<Match> sampleRule=Rule.fromUri("String_Node_Str","String_Node_Str",Match.of("String_Node_Str",TEMPLATE));
  return RuleRouter.of(singletonList(sampleRule));
}

Fixed version (ground truth):
private RuleRouter<Match> aRouter(final String pattern,final StaticBackendRoutes.RouteType routeType){
  final Rule<Match> sampleRule=Rule.fromUri(pattern,"String_Node_Str",Match.of("String_Node_Str",routeType));
  return RuleRouter.of(singletonList(sampleRule));
}
Program: 38741
Project: 38741
Buggy source:
private RequestContext aContext(){
  final Request request=mock(Request.class);
  when(request.uri()).thenReturn("String_Node_Str");
  when(request.service()).thenReturn(Optional.empty());
  when(request.method()).thenReturn("String_Node_Str");
  final RequestContext context=mock(RequestContext.class);
  when(context.request()).thenReturn(request);
  when(context.requestScopedClient()).thenReturn(mock(Client.class));
  return context;
}

Fixed version (ground truth):
private RequestContext aContext(){
  final Request request=mock(Request.class);
  when(request.uri()).thenReturn("String_Node_Str");
  when(request.service()).thenReturn(Optional.empty());
  when(request.method()).thenReturn("String_Node_Str");
  final RequestContext context=mock(RequestContext.class);
  when(context.request()).thenReturn(request);
  Client client=mock(Client.class);
  when(client.send(any())).thenThrow(new RuntimeException());
  when(context.requestScopedClient()).thenReturn(client);
  return context;
}
Program: 38742
Project: 38742
Buggy source:
private RuleRouter<Match> aRouter(){
  final Rule<Match> sampleRule=Rule.fromUri("String_Node_Str","String_Node_Str",Match.of("String_Node_Str"));
  return RuleRouter.of(singletonList(sampleRule));
}

Fixed version (ground truth):
private RuleRouter<Match> aRouter(){
  final Rule<Match> sampleRule=Rule.fromUri("String_Node_Str","String_Node_Str",Match.of("String_Node_Str",RouteType.TEMPLATE));
  return RuleRouter.of(singletonList(sampleRule));
}
Program: 38743
Project: 38743
Buggy source:
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  byte[] bytes=(byte[])msg;
  if (bytes.length == QuitPacket.QUIT.length && bytes[4] == MySQLPacket.COM_QUIT) {
    ctx.close();
    return;
  }
  AuthPacket authPacket=new AuthPacket();
  authPacket.read(bytes);
  frontendConnection.setHost(((InetSocketAddress)ctx.channel().remoteAddress()).getAddress().getHostAddress());
  frontendConnection.setPort(((InetSocketAddress)ctx.channel().remoteAddress()).getPort());
  frontendConnection.setLocalPort(((InetSocketAddress)ctx.channel().localAddress()).getPort());
  if (!checkUser(authPacket.user,frontendConnection.getHost())) {
    failure(ErrorCode.ER_ACCESS_DENIED_ERROR,"String_Node_Str" + authPacket.user + "String_Node_Str");
    return;
  }
  if (!checkPassword(authPacket.password,authPacket.user)) {
    failure(ErrorCode.ER_ACCESS_DENIED_ERROR,"String_Node_Str" + authPacket.user + "String_Node_Str");
    return;
  }
switch (checkSchema(authPacket.database,authPacket.user)) {
case ErrorCode.ER_BAD_DB_ERROR:
    failure(ErrorCode.ER_BAD_DB_ERROR,"String_Node_Str" + authPacket.database + "String_Node_Str");
  break;
case ErrorCode.ER_DBACCESS_DENIED_ERROR:
String s="String_Node_Str" + authPacket.user + "String_Node_Str"+ authPacket.database+ "String_Node_Str";
failure(ErrorCode.ER_DBACCESS_DENIED_ERROR,s);
break;
default :
success(authPacket,ctx);
}
super.channelRead(ctx,msg);
}

Fixed version (ground truth):
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  byte[] bytes=(byte[])msg;
  if (bytes.length == QuitPacket.QUIT.length && bytes[4] == MySQLPacket.COM_QUIT) {
    ctx.close();
    return;
  }
  AuthPacket authPacket=new AuthPacket();
  authPacket.read(bytes);
  frontendConnection.setHost(((InetSocketAddress)ctx.channel().remoteAddress()).getAddress().getHostAddress());
  frontendConnection.setPort(((InetSocketAddress)ctx.channel().remoteAddress()).getPort());
  frontendConnection.setLocalPort(((InetSocketAddress)ctx.channel().localAddress()).getPort());
  if (!checkUser(authPacket.user,frontendConnection.getHost())) {
    failure(ErrorCode.ER_ACCESS_DENIED_ERROR,"String_Node_Str" + authPacket.user + "String_Node_Str");
    return;
  }
  if (!checkPassword(authPacket.password,authPacket.user)) {
    failure(ErrorCode.ER_ACCESS_DENIED_ERROR,"String_Node_Str" + authPacket.user + "String_Node_Str");
    return;
  }
switch (checkSchema(authPacket.database,authPacket.user)) {
case ErrorCode.ER_BAD_DB_ERROR:
    failure(ErrorCode.ER_BAD_DB_ERROR,"String_Node_Str" + authPacket.database + "String_Node_Str");
  break;
case ErrorCode.ER_DBACCESS_DENIED_ERROR:
String s="String_Node_Str" + authPacket.user + "String_Node_Str"+ authPacket.database+ "String_Node_Str";
failure(ErrorCode.ER_DBACCESS_DENIED_ERROR,s);
break;
default :
success(authPacket,ctx);
}
}
Program: 38744
Project: 38744
Buggy source:
public static void response(ServerConnection c){
  ByteBuf buf=c.getChannelHandlerContext().alloc().buffer();
  buf=header.writeBuf(buf);
  for (  FieldPacket field : fields) {
    buf=field.writeBuf(buf);
  }
  buf=eof.writeBuf(buf);
  byte packetId=eof.packetId;
  RowDataPacket row=new RowDataPacket(FIELD_COUNT);
  row.add(VERSION_COMMENT);
  row.packetId=++packetId;
  buf=row.writeBuf(buf);
  EOFPacket lastEof=new EOFPacket();
  lastEof.packetId=++packetId;
  buf=lastEof.writeBuf(buf);
  c.getChannelHandlerContext().writeAndFlush(buf);
}

Fixed version (ground truth):
public static void response(ServerConnection c){
  ByteBuf buf=c.getChannelHandlerContext().alloc().buffer();
  buf=header.writeBuf(buf);
  for (  FieldPacket field : fields) {
    buf=field.writeBuf(buf);
  }
  buf=eof.writeBuf(buf);
  byte packetId=eof.packetId;
  RowDataPacket row=new RowDataPacket(FIELD_COUNT);
  row.add(VERSION_COMMENT);
  row.packetId=++packetId;
  buf=row.writeBuf(buf);
  EOFPacket lastEof=new EOFPacket();
  lastEof.packetId=++packetId;
  buf=lastEof.writeBuf(buf);
  c.writeByteBuf(buf);
}
Program: 38745
Project: 38745
Buggy source:
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  byte[] data=(byte[])msg;
  source.setChannelHandlerContext(ctx);
  source.getConfigLatch().await();
  try {
    HandshakePacket packet=this.source.getShakePacket();
    if (packet == null) {
      packet=new HandshakePacket();
      packet.read(data);
      source.setShakePacket(packet);
      source.setThreadId(packet.threadId);
      int charsetIndex=(packet.serverCharsetIndex & 0xff);
      String charset=CharsetUtil.getCharset(charsetIndex);
      if (charset != null) {
        source.setCharsetIndex(charsetIndex);
        source.setCharset(charset);
      }
 else {
        throw new RuntimeException("String_Node_Str" + charsetIndex);
      }
      source.authenticate();
    }
 else {
switch (data[4]) {
case OkPacket.FIELD_COUNT:
        source.setAuthenticated(true);
      ctx.pipeline().replace(BackendHandlerNameEnum.MYSQL_AUTH.getCode(),BackendHandlerNameEnum.MYSQL_CONN.getCode(),new BackendMySQLConnectionHandler(source));
    source.getHandler().connectionAcquired(source);
  break;
case ErrorPacket.FIELD_COUNT:
ErrorPacket err=new ErrorPacket();
err.read(data);
throw new RuntimeException(new String(err.message));
case EOFPacket.FIELD_COUNT:
auth323(data[3]);
break;
default :
throw new RuntimeException("String_Node_Str");
}
}
}
 catch (Exception e) {
this.source.getHandler().connectionError(e,source);
throw e;
}
super.channelRead(ctx,msg);
}

Fixed version (ground truth):
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  byte[] data=(byte[])msg;
  source.setChannelHandlerContext(ctx);
  source.getConfigLatch().await();
  try {
    HandshakePacket packet=this.source.getShakePacket();
    if (packet == null) {
      packet=new HandshakePacket();
      packet.read(data);
      source.setShakePacket(packet);
      source.setThreadId(packet.threadId);
      int charsetIndex=(packet.serverCharsetIndex & 0xff);
      String charset=CharsetUtil.getCharset(charsetIndex);
      if (charset != null) {
        source.setCharsetIndex(charsetIndex);
        source.setCharset(charset);
      }
 else {
        throw new RuntimeException("String_Node_Str" + charsetIndex);
      }
      source.authenticate();
    }
 else {
switch (data[4]) {
case OkPacket.FIELD_COUNT:
        source.setAuthenticated(true);
      ctx.pipeline().replace(BackendHandlerNameEnum.MYSQL_AUTH.getCode(),BackendHandlerNameEnum.MYSQL_CONN.getCode(),new BackendMySQLConnectionHandler(source));
    source.getHandler().connectionAcquired(source);
  break;
case ErrorPacket.FIELD_COUNT:
ErrorPacket err=new ErrorPacket();
err.read(data);
throw new RuntimeException(new String(err.message));
case EOFPacket.FIELD_COUNT:
auth323(data[3]);
break;
default :
throw new RuntimeException("String_Node_Str");
}
}
}
 catch (Exception e) {
this.source.getHandler().connectionError(e,source);
throw e;
}
}