nus-yam/ex-repair huggingface dataset:
Program: 164469
Project: 164469
Buggy source:
@Override public void damage(int dmg,Object src){
  restoreHealth=false;
  if (this.buff(Drowsy.class) != null) {
    Buff.detach(this,Drowsy.class);
    GLog.i("String_Node_Str");
  }
  super.damage(dmg,src);
  if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
    Buff.affect(this,Fury.class);
  }
}

Fixed version (ground truth):
@Override public void damage(int dmg,Object src){
  restoreHealth=false;
  if (this.buff(Drowsy.class) != null) {
    Buff.detach(this,Drowsy.class);
    GLog.w("String_Node_Str");
  }
  super.damage(dmg,src);
  if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
    Buff.affect(this,Fury.class);
  }
}
Program: 164470
Project: 164470
Buggy source:
@Override public void add(Buff buff){
  super.add(buff);
  if (buff instanceof Amok) {
    if (sprite != null) {
      sprite.showStatus(CharSprite.NEGATIVE,TXT_RAGE);
    }
    state=State.HUNTING;
  }
 else   if (buff instanceof Terror) {
    state=State.FLEEING;
  }
 else   if (buff instanceof Sleep || buff instanceof MagicalSleep) {
    if (sprite != null) {
      this.sprite().showSleep();
    }
    state=State.SLEEPING;
    this.sprite().showSleep();
    postpone(Sleep.SWS);
  }
}

Fixed version (ground truth):
@Override public void add(Buff buff){
  super.add(buff);
  if (buff instanceof Amok) {
    if (sprite != null) {
      sprite.showStatus(CharSprite.NEGATIVE,TXT_RAGE);
    }
    state=State.HUNTING;
  }
 else   if (buff instanceof Terror) {
    state=State.FLEEING;
  }
 else   if (buff instanceof Sleep || buff instanceof MagicalSleep) {
    state=State.SLEEPING;
    this.sprite().showSleep();
    postpone(Sleep.SWS);
  }
}
Program: 164471
Project: 164471
Buggy source:
@Override public void execute(final Hero hero,String action){
  if (action.equals(AC_BLESS)) {
    DewVial vial=hero.belongings.getItem(DewVial.class);
    if (vial != null) {
      blessed=true;
      vial.empty();
      GLog.p(TXT_BLESS);
      hero.spend(1f);
      hero.busy();
      Sample.INSTANCE.play(Assets.SND_DRINK);
      hero.sprite.operate(hero.pos);
    }
  }
 else {
    super.execute(hero,action);
  }
}

Fixed version (ground truth):
@Override public void execute(final Hero hero,String action){
  if (action.equals(AC_BLESS)) {
    DewVial vial=hero.belongings.getItem(DewVial.class);
    if (vial != null) {
      blessed=true;
      vial.empty();
      GLog.p(TXT_BLESS);
      hero.spend(1f);
      hero.busy();
      Sample.INSTANCE.play(Assets.SND_DRINK);
      CellEmitter.get(hero.pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
      hero.sprite.operate(hero.pos);
    }
  }
 else {
    super.execute(hero,action);
  }
}
Program: 164474
Project: 164474
Buggy source:
public void setKnown(){
  if (!isKnown()) {
    handler.know(this);
  }
  Badges.validateAllPotionsIdentified();
}

Fixed version (ground truth):
public void setKnown(){
  if (!ownedByFruit) {
    if (!isKnown()) {
      handler.know(this);
    }
    Badges.validateAllPotionsIdentified();
  }
}
Program: 164475
Project: 164475
Buggy source:
@Override protected void doRead(){
  curUser.sprite.centerEmitter().start(Speck.factory(Speck.NOTE),0.3f,5);
  Sample.INSTANCE.play(Assets.SND_LULLABY);
  Invisibility.dispel();
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
    if (Level.fieldOfView[mob.pos]) {
      Buff.affect(mob,Drowsy.class);
    }
  }
  Buff.affect(curUser,Drowsy.class);
  GLog.i("String_Node_Str");
  setKnown();
  curUser.spendAndNext(TIME_TO_READ);
}

Fixed version (ground truth):
@Override protected void doRead(){
  curUser.sprite.centerEmitter().start(Speck.factory(Speck.NOTE),0.3f,5);
  Sample.INSTANCE.play(Assets.SND_LULLABY);
  Invisibility.dispel();
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
    if (Level.fieldOfView[mob.pos]) {
      Buff.affect(mob,Drowsy.class);
      mob.sprite.centerEmitter().start(Speck.factory(Speck.NOTE),0.3f,5);
    }
  }
  Buff.affect(curUser,Drowsy.class);
  GLog.i("String_Node_Str");
  setKnown();
  curUser.spendAndNext(TIME_TO_READ);
}
Program: 164476
Project: 164476
Buggy source:
@Override public boolean act(){
  if (target.pos != pos || healTot <= 0) {
    detach();
  }
  if (count == 5) {
    if (healTot <= healCurr) {
      target.HP=Math.min(target.HT,target.HP + healTot);
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      detach();
    }
 else {
      target.HP=Math.min(target.HT,target.HP + healCurr);
      healTot-=healCurr;
      healCurr=Math.min(healCurr + healCurr - 1,(int)(target.HT * 0.15));
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
    count=1;
  }
 else {
    count++;
  }
  spend(STEP);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.pos != pos || level <= 0) {
    detach();
  }
  if (count == 5) {
    if (level <= healCurr) {
      target.HP=Math.min(target.HT,target.HP + level);
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      detach();
    }
 else {
      target.HP=Math.min(target.HT,target.HP + (int)(healCurr * .025 * target.HT));
      level-=(healCurr * .025 * target.HT);
      if (healCurr < 6)       healCurr++;
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
    count=1;
  }
 else {
    count++;
  }
  spend(STEP);
  return true;
}
Program: 164477
Project: 164477
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(POS,pos);
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(POS,pos);
  bundle.put(HEALCURR,healCurr);
  bundle.put(COUNT,count);
  bundle.put(LEVEL,level);
}
Program: 164478
Project: 164478
Buggy source:
@Override public void activate(Char ch){
  super.activate(ch);
  if (ch != null) {
    Buff.affect(ch,Health.class);
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.get(pos).start(ShaftParticle.FACTORY,0.2f,3);
  }
}

Fixed version (ground truth):
@Override public void activate(Char ch){
  super.activate(ch);
  if (ch != null) {
    Buff.affect(ch,Health.class).level=ch.HT;
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.get(pos).start(ShaftParticle.FACTORY,0.2f,3);
  }
}
Program: 164479
Project: 164479
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  pos=bundle.getInt(POS);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  pos=bundle.getInt(POS);
  if (!bundle.contains(LEVEL)) {
    return;
  }
  healCurr=bundle.getInt(HEALCURR);
  count=bundle.getInt(COUNT);
  level=bundle.getInt(LEVEL);
}
Program: 164480
Project: 164480
Buggy source:
@Override public String toString(){
  return Utils.format("String_Node_Str",healTot);
}

Fixed version (ground truth):
@Override public String toString(){
  return Utils.format("String_Node_Str",level);
}
Program: 164481
Project: 164481
Buggy source:
@Override public boolean attachTo(Char target){
  pos=target.pos;
  healTot=target.HT;
  return super.attachTo(target);
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  pos=target.pos;
  return super.attachTo(target);
}
Program: 164482
Project: 164482
Buggy source:
public int absorb(int damage){
  healTot-=damage;
  if (healTot <= 0)   detach();
  return damage;
}

Fixed version (ground truth):
public int absorb(int damage){
  level-=damage;
  if (level <= 0)   detach();
  return damage;
}
Program: 164484
Project: 164484
Buggy source:
@Override public void onResponse(Response<UserResponse> response,Retrofit retrofit){
  if (isDestroyed() || isFinishing())   return;
  if (response != null && response.body() != null) {
    UserResponse userResponse=response.body();
    if (mSelectedUser != null) {
      mSelectedUser.copy(userResponse.data);
    }
 else {
      mSelectedUser=userResponse.data;
    }
    mSelectedUser.setLastSeen(System.currentTimeMillis());
    if (mSelectedUser.isSelf(app) && !TextUtils.isEmpty(mSelectedUser.getAccessToken())) {
      SqlHelper.getInstance(getApplicationContext()).updateUserInfo(mSelectedUser);
    }
 else {
      SqlHelper.getInstance(getApplicationContext()).insertProfile(mSelectedUser);
    }
    mAdapter=new ProfilePager(getApplicationContext(),getFragmentManager(),mSelectedUser);
    mPager.setAdapter(mAdapter);
    mSlidingTabs.setupWithViewPager(mPager);
    mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
    supportInvalidateOptionsMenu();
  }
 else {
    ViewUtils.setErrorText(mMultiView,R.id.errorMessage,R.string.error_generic);
    mMultiView.setViewState(MultiStateView.VIEW_STATE_ERROR);
  }
}

Fixed version (ground truth):
@Override public void onResponse(Response<UserResponse> response,Retrofit retrofit){
  if (isDestroyed() || isFinishing())   return;
  if (response != null && response.body() != null) {
    UserResponse userResponse=response.body();
    if (mSelectedUser != null) {
      mSelectedUser.copy(userResponse.data);
    }
 else {
      mSelectedUser=userResponse.data;
    }
    mSelectedUser.setLastSeen(System.currentTimeMillis());
    if (mSelectedUser.isSelf(app) && !TextUtils.isEmpty(mSelectedUser.getAccessToken())) {
      SqlHelper.getInstance(getApplicationContext()).updateUserInfo(mSelectedUser);
    }
 else {
      SqlHelper.getInstance(getApplicationContext()).insertProfile(mSelectedUser);
    }
    mAdapter=new ProfilePager(getApplicationContext(),getFragmentManager(),mSelectedUser);
    mPager.setAdapter(mAdapter);
    mSlidingTabs.setupWithViewPager(mPager);
    mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
    supportInvalidateOptionsMenu();
  }
 else {
    ViewUtils.setErrorText(mMultiView,R.id.errorMessage,getString(R.string.profile_not_found,username));
    mMultiView.setViewState(MultiStateView.VIEW_STATE_ERROR);
  }
}
Program: 164485
Project: 164485
Buggy source:
public boolean onError(MediaPlayer mp,int framework_err,int impl_err){
  Log.d(TAG,"String_Node_Str" + framework_err + "String_Node_Str"+ impl_err);
  mCurrentState=STATE_ERROR;
  mTargetState=STATE_ERROR;
  if (mMediaController != null) {
    mMediaController.hide();
  }
  if (mOnErrorListener != null) {
    if (mOnErrorListener.onError(mMediaPlayer,framework_err,impl_err)) {
      return true;
    }
  }
  if (getWindowToken() != null) {
    mMediaPlayer.setOnErrorListener(null);
    new AlertDialog.Builder(getContext()).setTitle(R.string.error_generic).setMessage(R.string.loading_image_error).setPositiveButton(R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int whichButton){
        if (mOnCompletionListener != null) {
          mOnCompletionListener.onCompletion(mMediaPlayer);
        }
      }
    }
).setCancelable(false).show();
  }
  return true;
}

Fixed version (ground truth):
public boolean onError(MediaPlayer mp,int framework_err,int impl_err){
  Log.d(TAG,"String_Node_Str" + framework_err + "String_Node_Str"+ impl_err);
  mCurrentState=STATE_ERROR;
  mTargetState=STATE_ERROR;
  if (mMediaController != null) {
    mMediaController.hide();
  }
  if (mOnErrorListener != null) {
    if (mOnErrorListener.onError(mMediaPlayer,framework_err,impl_err)) {
      return true;
    }
    mOnErrorListener=null;
  }
  if (getWindowToken() != null) {
    mMediaPlayer.setOnErrorListener(null);
    new AlertDialog.Builder(getContext()).setTitle(R.string.error_generic).setMessage(R.string.loading_image_error).setPositiveButton(R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int whichButton){
        if (mOnCompletionListener != null) {
          mOnCompletionListener.onCompletion(mMediaPlayer);
        }
      }
    }
).setCancelable(false).show();
  }
  return true;
}
Program: 164486
Project: 164486
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (user == null)   throw new IllegalStateException("String_Node_Str");
  getSupportActionBar().setTitle(R.string.notifications);
  setContentView(R.layout.activity_notifications);
  mList.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
  if (savedInstanceState != null) {
    List<ImgurNotification> notifications=savedInstanceState.getParcelableArrayList(KEY_ITEMS);
    if (notifications != null && !notifications.isEmpty()) {
      int position=savedInstanceState.getInt(KEY_POSIION,0);
      mList.setAdapter(mAdapter=new NotificationAdapter(this,notifications,this));
      mList.scrollToPosition(position);
      mMultiView.setViewState(MultiStateView.ViewState.CONTENT);
    }
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (user == null)   throw new IllegalStateException("String_Node_Str");
  getSupportActionBar().setTitle(R.string.notifications);
  setContentView(R.layout.activity_notifications);
  mList.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
  if (savedInstanceState != null) {
    List<ImgurNotification> notifications=savedInstanceState.getParcelableArrayList(KEY_ITEMS);
    if (notifications != null && !notifications.isEmpty()) {
      int position=savedInstanceState.getInt(KEY_POSIION,0);
      mList.setAdapter(mAdapter=new NotificationAdapter(this,notifications,this));
      mList.scrollToPosition(position);
      mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
    }
  }
}
Program: 164487
Project: 164487
Buggy source:
@OnClick(R.id.errorButton) @Override public void onClick(View v){
  if (v.getId() == R.id.errorButton) {
    mMultiView.setViewState(MultiStateView.ViewState.LOADING);
    fetchNotifications();
    return;
  }
  ImgurNotification notification=mAdapter.getItem(mList.getChildAdapterPosition(v));
  if (notification.getType() == ImgurNotification.TYPE_MESSAGE) {
    ImgurConvo convo=new ImgurConvo(notification.getContentId(),notification.getAuthor(),0);
    startActivity(ConvoThreadActivity.createIntent(getApplicationContext(),convo));
  }
 else {
    String url="String_Node_Str" + notification.getContentId();
    Intent intent=ViewActivity.createIntent(getApplicationContext(),url,!TextUtils.isEmpty(notification.getAlbumCover()));
    startActivity(intent);
  }
}

Fixed version (ground truth):
@OnClick(R.id.errorButton) @Override public void onClick(View v){
  if (v.getId() == R.id.errorButton) {
    mMultiView.setViewState(MultiStateView.VIEW_STATE_LOADING);
    fetchNotifications();
    return;
  }
  ImgurNotification notification=mAdapter.getItem(mList.getChildAdapterPosition(v));
  if (notification.getType() == ImgurNotification.TYPE_MESSAGE) {
    ImgurConvo convo=new ImgurConvo(notification.getContentId(),notification.getAuthor(),0);
    startActivity(ConvoThreadActivity.createIntent(getApplicationContext(),convo));
  }
 else {
    String url="String_Node_Str" + notification.getContentId();
    Intent intent=ViewActivity.createIntent(getApplicationContext(),url,!TextUtils.isEmpty(notification.getAlbumCover()));
    startActivity(intent);
  }
}
Program: 164488
Project: 164488
Buggy source:
@Override public void success(NotificationResponse notificationResponse,Response response){
  if (notificationResponse != null && notificationResponse.data != null) {
    app.getSql().insertNotifications(notificationResponse);
    List<ImgurNotification> notifications=app.getSql().getNotifications();
    if (notifications.isEmpty() && (mAdapter == null || mAdapter.isEmpty())) {
      mMultiView.setViewState(MultiStateView.ViewState.EMPTY);
    }
 else {
      if (mAdapter != null) {
        mAdapter.addItems(notifications);
      }
 else {
        mAdapter=new NotificationAdapter(NotificationActivity.this,notifications,NotificationActivity.this);
        mList.setAdapter(mAdapter);
      }
      mMultiView.setViewState(MultiStateView.ViewState.CONTENT);
    }
  }
 else {
    mMultiView.setErrorText(R.id.errorMessage,R.string.error_generic);
    mMultiView.setViewState(MultiStateView.ViewState.ERROR);
  }
}

Fixed version (ground truth):
@Override public void success(NotificationResponse notificationResponse,Response response){
  if (notificationResponse != null && notificationResponse.data != null) {
    app.getSql().insertNotifications(notificationResponse);
    List<ImgurNotification> notifications=app.getSql().getNotifications();
    if (notifications.isEmpty() && (mAdapter == null || mAdapter.isEmpty())) {
      mMultiView.setViewState(MultiStateView.VIEW_STATE_EMPTY);
    }
 else {
      if (mAdapter != null) {
        mAdapter.addItems(notifications);
      }
 else {
        mAdapter=new NotificationAdapter(NotificationActivity.this,notifications,NotificationActivity.this);
        mList.setAdapter(mAdapter);
      }
      mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
    }
  }
 else {
    mMultiView.setErrorText(R.id.errorMessage,R.string.error_generic);
    mMultiView.setViewState(MultiStateView.VIEW_STATE_ERROR);
  }
}
Program: 164489
Project: 164489
Buggy source:
@Override public void failure(RetrofitError error){
  if (mAdapter == null || mAdapter.isEmpty()) {
    mMultiView.setErrorText(R.id.errorMessage,ApiClient.getErrorCode(error));
    mMultiView.setViewState(MultiStateView.ViewState.ERROR);
  }
 else {
    SnackBar.show(NotificationActivity.this,ApiClient.getErrorCode(error));
    mMultiView.setViewState(MultiStateView.ViewState.CONTENT);
  }
}

Fixed version (ground truth):
@Override public void failure(RetrofitError error){
  if (mAdapter == null || mAdapter.isEmpty()) {
    mMultiView.setErrorText(R.id.errorMessage,ApiClient.getErrorCode(error));
    mMultiView.setViewState(MultiStateView.VIEW_STATE_ERROR);
  }
 else {
    SnackBar.show(NotificationActivity.this,ApiClient.getErrorCode(error));
    mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
  }
}
Program: 164491
Project: 164491
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (mAdapter == null || mAdapter.isEmpty()) {
    List<ImgurNotification> notifications=app.getSql().getNotifications();
    if (!notifications.isEmpty()) {
      LogUtil.v(TAG,"String_Node_Str");
      mAdapter=new NotificationAdapter(this,notifications,this);
      mList.setAdapter(mAdapter);
      mMultiView.setViewState(MultiStateView.ViewState.CONTENT);
      String ids=app.getSql().getNotificationIds();
      if (!TextUtils.isEmpty(ids)) {
        app.getSql().deleteNotifications();
        ApiClient.getService().markNotificationsRead(ids,new Callback<BasicResponse>(){
          @Override public void success(          BasicResponse basicResponse,          Response response){
          }
          @Override public void failure(          RetrofitError error){
            LogUtil.e(TAG,"String_Node_Str",error);
          }
        }
);
      }
    }
 else {
      LogUtil.v(TAG,"String_Node_Str");
      mMultiView.setViewState(MultiStateView.ViewState.LOADING);
      fetchNotifications();
    }
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (mAdapter == null || mAdapter.isEmpty()) {
    List<ImgurNotification> notifications=app.getSql().getNotifications();
    if (!notifications.isEmpty()) {
      LogUtil.v(TAG,"String_Node_Str");
      mAdapter=new NotificationAdapter(this,notifications,this);
      mList.setAdapter(mAdapter);
      mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
      String ids=app.getSql().getNotificationIds();
      if (!TextUtils.isEmpty(ids)) {
        app.getSql().deleteNotifications();
        ApiClient.getService().markNotificationsRead(ids,new Callback<BasicResponse>(){
          @Override public void success(          BasicResponse basicResponse,          Response response){
          }
          @Override public void failure(          RetrofitError error){
            LogUtil.e(TAG,"String_Node_Str",error);
          }
        }
);
      }
    }
 else {
      LogUtil.v(TAG,"String_Node_Str");
      mMultiView.setViewState(MultiStateView.VIEW_STATE_LOADING);
      fetchNotifications();
    }
  }
}
Program: 164492
Project: 164492
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.refresh:
    mMultiView.setViewState(MultiStateView.ViewState.LOADING);
  fetchNotifications();
break;
}
return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.refresh:
    mMultiView.setViewState(MultiStateView.VIEW_STATE_LOADING);
  fetchNotifications();
break;
}
return super.onOptionsItemSelected(item);
}
Program: 164494
Project: 164494
Buggy source:
@Override public Cursor runQuery(CharSequence constraint){
  return app.getSql().getPreviousGallerySearches(constraint);
}

Fixed version (ground truth):
@Override public Cursor runQuery(CharSequence constraint){
  return app.getSql().getPreviousGallerySearches(constraint.toString());
}
Program: 164496
Project: 164496
Buggy source:
/** 
 * Called when a successful search has been completed by the API
 */
public void onSuccessfulSearch(){
  app.getSql().addPreviousGallerySearch(mQuery);
  if (mSearchAdapter == null) {
    mSearchAdapter=new SearchAdapter(getActivity(),app.getSql().getSubReddits(mQuery),DBContracts.GallerySearchContract.COLUMN_NAME);
    mSearchView.setSuggestionsAdapter(mSearchAdapter);
  }
 else {
    mSearchAdapter.changeCursor(app.getSql().getSubReddits(mQuery));
  }
  mSearchAdapter.notifyDataSetChanged();
}

Fixed version (ground truth):
/** 
 * Called when a successful search has been completed by the API
 */
public void onSuccessfulSearch(){
  app.getSql().addPreviousGallerySearch(mQuery);
  if (mSearchAdapter == null) {
    mSearchAdapter=new SearchAdapter(getActivity(),app.getSql().getPreviousGallerySearches(mQuery),DBContracts.GallerySearchContract.COLUMN_NAME);
    mSearchView.setSuggestionsAdapter(mSearchAdapter);
  }
 else {
    mSearchAdapter.changeCursor(app.getSql().getPreviousGallerySearches(mQuery));
  }
  mSearchAdapter.notifyDataSetChanged();
}
Program: 164497
Project: 164497
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MESSAGE_ACTION_COMPLETE:
    if (msg.obj instanceof ImgurBaseObject) {
      setupFragmentWithObject((ImgurBaseObject)msg.obj);
    }
 else     if (msg.obj instanceof List && mImgurObject instanceof ImgurAlbum) {
      ((ImgurAlbum)mImgurObject).addPhotosToAlbum((List<ImgurPhoto>)msg.obj);
      mPhotoAdapter=new PhotoAdapter(getActivity(),((ImgurAlbum)mImgurObject).getAlbumPhotos(),ImgurViewFragment.this);
      createHeader();
      mListView.setAdapter(mPhotoAdapter);
      mMultiView.setViewState(MultiStateView.ViewState.CONTENT);
    }
 else {
      mMultiView.setErrorText(R.id.errorMessage,R.string.error_generic);
      mMultiView.setViewState(MultiStateView.ViewState.ERROR);
    }
  break;
case MESSAGE_ACTION_FAILED:
mMultiView.setErrorText(R.id.errorMessage,ApiClient.getErrorCodeStringResource((Integer)msg.obj));
mMultiView.setViewState(MultiStateView.ViewState.ERROR);
break;
case MESSAGE_TAGS_RECEIVED:
if (msg.obj instanceof ArrayList) {
mImgurObject.setTags((ArrayList<String>)msg.obj);
displayTags(true);
}
break;
default :
super.handleMessage(msg);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MESSAGE_ACTION_COMPLETE:
    if (getActivity() == null || !isAdded() || isRemoving())     return;
  if (msg.obj instanceof ImgurBaseObject) {
    setupFragmentWithObject((ImgurBaseObject)msg.obj);
  }
 else   if (msg.obj instanceof List && mImgurObject instanceof ImgurAlbum) {
    ((ImgurAlbum)mImgurObject).addPhotosToAlbum((List<ImgurPhoto>)msg.obj);
    mPhotoAdapter=new PhotoAdapter(getActivity(),((ImgurAlbum)mImgurObject).getAlbumPhotos(),ImgurViewFragment.this);
    createHeader();
    mListView.setAdapter(mPhotoAdapter);
    mMultiView.setViewState(MultiStateView.ViewState.CONTENT);
  }
 else {
    mMultiView.setErrorText(R.id.errorMessage,R.string.error_generic);
    mMultiView.setViewState(MultiStateView.ViewState.ERROR);
  }
break;
case MESSAGE_ACTION_FAILED:
mMultiView.setErrorText(R.id.errorMessage,ApiClient.getErrorCodeStringResource((Integer)msg.obj));
mMultiView.setViewState(MultiStateView.ViewState.ERROR);
break;
case MESSAGE_TAGS_RECEIVED:
if (msg.obj instanceof ArrayList) {
mImgurObject.setTags((ArrayList<String>)msg.obj);
displayTags(true);
}
break;
default :
super.handleMessage(msg);
break;
}
}
Program: 164498
Project: 164498
Buggy source:
@Override public Cursor runQuery(CharSequence constraint){
  return app.getSql().getSubReddits(constraint);
}

Fixed version (ground truth):
@Override public Cursor runQuery(CharSequence constraint){
  return app.getSql().getSubReddits(constraint.toString());
}
Program: 164499
Project: 164499
Buggy source:
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  inflater.inflate(R.menu.reddit,menu);
  mSearchMenuItem=menu.findItem(R.id.search);
  mSearchView=(SearchView)MenuItemCompat.getActionView(mSearchMenuItem);
  mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener(){
    @Override public boolean onQueryTextSubmit(    String text){
      return search(text);
    }
    @Override public boolean onQueryTextChange(    String s){
      return false;
    }
  }
);
  mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener(){
    @Override public boolean onSuggestionSelect(    int position){
      String title=mCursorAdapter.getTitle(position);
      return search(title);
    }
    @Override public boolean onSuggestionClick(    int position){
      String title=mCursorAdapter.getTitle(position);
      return search(title);
    }
  }
);
  if (getActivity() != null) {
    mSearchView.setQueryHint(getString(R.string.enter_sub_reddit));
    mCursorAdapter=new SearchAdapter(getActivity(),app.getSql().getSubReddits(),DBContracts.SubRedditContract.COLUMN_NAME);
    mCursorAdapter.setFilterQueryProvider(new FilterQueryProvider(){
      @Override public Cursor runQuery(      CharSequence constraint){
        return app.getSql().getSubReddits(constraint);
      }
    }
);
    mSearchView.setSuggestionsAdapter(mCursorAdapter);
  }
  super.onCreateOptionsMenu(menu,inflater);
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  inflater.inflate(R.menu.reddit,menu);
  mSearchMenuItem=menu.findItem(R.id.search);
  mSearchView=(SearchView)MenuItemCompat.getActionView(mSearchMenuItem);
  mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener(){
    @Override public boolean onQueryTextSubmit(    String text){
      return search(text);
    }
    @Override public boolean onQueryTextChange(    String s){
      return false;
    }
  }
);
  mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener(){
    @Override public boolean onSuggestionSelect(    int position){
      String title=mCursorAdapter.getTitle(position);
      return search(title);
    }
    @Override public boolean onSuggestionClick(    int position){
      String title=mCursorAdapter.getTitle(position);
      return search(title);
    }
  }
);
  if (getActivity() != null) {
    mSearchView.setQueryHint(getString(R.string.enter_sub_reddit));
    mCursorAdapter=new SearchAdapter(getActivity(),app.getSql().getSubReddits(),DBContracts.SubRedditContract.COLUMN_NAME);
    mCursorAdapter.setFilterQueryProvider(new FilterQueryProvider(){
      @Override public Cursor runQuery(      CharSequence constraint){
        return app.getSql().getSubReddits(constraint.toString());
      }
    }
);
    mSearchView.setSuggestionsAdapter(mCursorAdapter);
  }
  super.onCreateOptionsMenu(menu,inflater);
}
Program: 164500
Project: 164500
Buggy source:
/** 
 * Returns subreddits that match the given name
 * @param name
 * @return
 */
public Cursor getSubReddits(CharSequence name){
  String sql=SubRedditContract.SEARCH_SUBREDDIT_SQL + name + "String_Node_Str";
  return getReadableDatabase().rawQuery(sql,null);
}

Fixed version (ground truth):
/** 
 * Returns subreddits that match the given name
 * @param name
 * @return
 */
public Cursor getSubReddits(String name){
  name="String_Node_Str" + name + "String_Node_Str";
  return getReadableDatabase().rawQuery(SubRedditContract.SEARCH_SUBREDDIT_SQL,new String[]{name});
}
Program: 164501
Project: 164501
Buggy source:
public Cursor getPreviousGallerySearches(CharSequence name){
  String sql=GallerySearchContract.SEARCH_GALLERY_SQL + name + "String_Node_Str";
  return getReadableDatabase().rawQuery(sql,null);
}

Fixed version (ground truth):
public Cursor getPreviousGallerySearches(String name){
  name="String_Node_Str" + name + "String_Node_Str";
  return getReadableDatabase().rawQuery(GallerySearchContract.SEARCH_GALLERY_SQL,new String[]{name});
}
Program: 164506
Project: 164506
Buggy source:
private void onListItemClick(int position){
  if (position >= 0) {
    boolean shouldClose=mCommentAdapter.setSelectedIndex(position);
    if (shouldClose) {
      mSelectedComment=null;
    }
 else {
      mSelectedComment=mCommentAdapter.getItem(position);
      showCommentSheet();
    }
  }
 else {
    previousComments(mCommentAdapter.getItem(0));
  }
}

Fixed version (ground truth):
private void onListItemClick(int position){
  if (mCommentAdapter == null)   return;
  if (position >= 0) {
    boolean shouldClose=mCommentAdapter.setSelectedIndex(position);
    if (shouldClose) {
      mSelectedComment=null;
    }
 else {
      mSelectedComment=mCommentAdapter.getItem(position);
      showCommentSheet();
    }
  }
 else {
    previousComments(mCommentAdapter.getItem(0));
  }
}
Program: 164507
Project: 164507
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mCommentArray.size() > 0) {
    long key=mCommentArray.keyAt(0);
    outState.putParcelableArrayList(KEY_COMMENT,mCommentArray.get(key));
  }
 else   if (mCommentAdapter != null && !mCommentAdapter.isEmpty()) {
    outState.putParcelableArrayList(KEY_COMMENT,mCommentAdapter.retainItems());
  }
  outState.putBoolean(KEY_LOAD_COMMENTS,mLoadComments);
  outState.putString(KEY_SORT,mCommentSort.getSort());
  if (mPagerAdapter != null && !mPagerAdapter.isEmpty()) {
    outState.putInt(KEY_POSITION,mViewPager.getCurrentItem());
    outState.putParcelableArrayList(KEY_OBJECTS,mPagerAdapter.retainItems());
  }
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mCommentArray.size() > 0) {
    long key=mCommentArray.keyAt(0);
    outState.putParcelableArrayList(KEY_COMMENT,mCommentArray.get(key));
  }
 else   if (mCommentAdapter != null && !mCommentAdapter.isEmpty()) {
    outState.putParcelableArrayList(KEY_COMMENT,mCommentAdapter.retainItems());
  }
  outState.putBoolean(KEY_LOAD_COMMENTS,mLoadComments);
  outState.putString(KEY_SORT,mCommentSort.getSort());
  if (mPagerAdapter != null && !mPagerAdapter.isEmpty()) {
    outState.putInt(KEY_POSITION,mViewPager.getCurrentItem());
    outState.putParcelableArrayList(KEY_OBJECTS,mPagerAdapter.retainItems());
  }
  if (mSlidingPane != null)   outState.putBoolean(KEY_PANEL_EXPANDED,mSlidingPane.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED);
}
Program: 164508
Project: 164508
Buggy source:
@Override protected void onResume(){
  super.onResume();
  EventBus.getDefault().register(this);
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (!EventBus.getDefault().isRegistered(this)) {
    EventBus.getDefault().register(this);
  }
}
Program: 164510
Project: 164510
Buggy source:
@Override public void onLinkTap(View view,String url){
  if (!TextUtils.isEmpty(url)) {
    LinkUtils.LinkMatch match=LinkUtils.findImgurLinkMatch(url);
switch (match) {
case GALLERY:
case ALBUM:
      Intent intent=ViewActivity.createIntent(getApplicationContext(),url,match == LinkUtils.LinkMatch.ALBUM).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
  break;
case IMAGE_URL:
PopupImageDialogFragment.getInstance(url,url.endsWith("String_Node_Str"),true,false).show(getFragmentManager(),"String_Node_Str");
break;
case VIDEO_URL:
PopupImageDialogFragment.getInstance(url,true,true,true).show(getFragmentManager(),"String_Node_Str");
break;
case IMAGE:
String[] split=url.split("String_Node_Str");
PopupImageDialogFragment.getInstance(split[split.length - 1],false,false,false).show(getFragmentManager(),"String_Node_Str");
break;
case NONE:
default :
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));
if (browserIntent.resolveActivity(getPackageManager()) != null) {
startActivity(browserIntent);
}
 else {
SnackBar.show(ViewActivity.this,R.string.cant_launch_intent);
}
break;
}
}
 else {
onListItemClick(mCommentList.getPositionForView(view) - mCommentList.getHeaderViewsCount());
}
}

Fixed version (ground truth):
@Override public void onLinkTap(View view,String url){
  if (!TextUtils.isEmpty(url) && !isFinishing()) {
    LinkUtils.LinkMatch match=LinkUtils.findImgurLinkMatch(url);
switch (match) {
case GALLERY:
case ALBUM:
      Intent intent=ViewActivity.createIntent(getApplicationContext(),url,match == LinkUtils.LinkMatch.ALBUM).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
  break;
case IMAGE_URL:
PopupImageDialogFragment.getInstance(url,url.endsWith("String_Node_Str"),true,false).show(getFragmentManager(),"String_Node_Str");
break;
case VIDEO_URL:
PopupImageDialogFragment.getInstance(url,true,true,true).show(getFragmentManager(),"String_Node_Str");
break;
case IMAGE:
String[] split=url.split("String_Node_Str");
PopupImageDialogFragment.getInstance(split[split.length - 1],false,false,false).show(getFragmentManager(),"String_Node_Str");
break;
case NONE:
default :
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));
if (browserIntent.resolveActivity(getPackageManager()) != null) {
startActivity(browserIntent);
}
 else {
SnackBar.show(ViewActivity.this,R.string.cant_launch_intent);
}
break;
}
}
 else {
onListItemClick(mCommentList.getPositionForView(view) - mCommentList.getHeaderViewsCount());
}
}
Program: 164511
Project: 164511
Buggy source:
@Override public void onVideoDownloadComplete(File file){
  displayVideo(file);
}

Fixed version (ground truth):
@Override public void onVideoDownloadComplete(File file){
  if (isAdded() && isResumed()) {
    displayVideo(file);
  }
}
Program: 164512
Project: 164512
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mCommentArray.size() > 0) {
    long key=mCommentArray.keyAt(0);
    outState.putParcelableArrayList(KEY_COMMENT,mCommentArray.get(key));
  }
 else   if (!mCommentAdapter.isEmpty()) {
    outState.putParcelableArrayList(KEY_COMMENT,mCommentAdapter.retainItems());
  }
  outState.putBoolean(KEY_LOAD_COMMENTS,mLoadComments);
  outState.putString(KEY_SORT,mCommentSort.getSort());
  if (mPagerAdapter != null && !mPagerAdapter.isEmpty()) {
    outState.putInt(KEY_POSITION,mViewPager.getCurrentItem());
    outState.putParcelableArrayList(KEY_OBJECTS,mPagerAdapter.retainItems());
  }
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mCommentArray.size() > 0) {
    long key=mCommentArray.keyAt(0);
    outState.putParcelableArrayList(KEY_COMMENT,mCommentArray.get(key));
  }
 else   if (mCommentAdapter != null && !mCommentAdapter.isEmpty()) {
    outState.putParcelableArrayList(KEY_COMMENT,mCommentAdapter.retainItems());
  }
  outState.putBoolean(KEY_LOAD_COMMENTS,mLoadComments);
  outState.putString(KEY_SORT,mCommentSort.getSort());
  if (mPagerAdapter != null && !mPagerAdapter.isEmpty()) {
    outState.putInt(KEY_POSITION,mViewPager.getCurrentItem());
    outState.putParcelableArrayList(KEY_OBJECTS,mPagerAdapter.retainItems());
  }
}
Program: 164513
Project: 164513
Buggy source:
/** 
 * Deletes all of the cache, including the unused partition (external/internal)
 */
public void deleteAllCache(){
  mImageLoader.clearDiskCache();
  mImageLoader.clearMemoryCache();
  VideoCache.getInstance().deleteCache();
  String cacheKey=mPref.getString(SettingsActivity.KEY_CACHE_LOC,SettingsActivity.CACHE_LOC_INTERNAL);
  if (SettingsActivity.CACHE_LOC_EXTERNAL.equals(cacheKey)) {
    FileUtil.deleteDirectory(getCacheDir());
    File videoCache=new File(getCacheDir(),"String_Node_Str");
    FileUtil.deleteDirectory(videoCache);
  }
 else   if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
    if (FileUtil.isFileValid(getExternalCacheDir())) {
      File cache=getExternalCacheDir();
      FileUtil.deleteDirectory(cache);
      File videoCache=new File(cache,"String_Node_Str");
      FileUtil.deleteDirectory(videoCache);
    }
  }
}

Fixed version (ground truth):
/** 
 * Deletes all of the cache, including the unused partition (external/internal)
 */
public void deleteAllCache(){
  ImageLoader imageLoader=getImageLoader();
  imageLoader.clearDiskCache();
  imageLoader.clearMemoryCache();
  VideoCache.getInstance().deleteCache();
  String cacheKey=mPref.getString(SettingsActivity.KEY_CACHE_LOC,SettingsActivity.CACHE_LOC_INTERNAL);
  if (SettingsActivity.CACHE_LOC_EXTERNAL.equals(cacheKey)) {
    FileUtil.deleteDirectory(getCacheDir());
    File videoCache=new File(getCacheDir(),"String_Node_Str");
    FileUtil.deleteDirectory(videoCache);
  }
 else   if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
    if (FileUtil.isFileValid(getExternalCacheDir())) {
      File cache=getExternalCacheDir();
      FileUtil.deleteDirectory(cache);
      File videoCache=new File(cache,"String_Node_Str");
      FileUtil.deleteDirectory(videoCache);
    }
  }
}
Program: 164514
Project: 164514
Buggy source:
public static OpenImgurApp getInstance(Context context){
  return (OpenImgurApp)context.getApplicationContext();
}

Fixed version (ground truth):
public static OpenImgurApp getInstance(Context context){
  return context != null ? (OpenImgurApp)context.getApplicationContext() : instance;
}
Program: 164515
Project: 164515
Buggy source:
/** 
 * Changes the comment list to the previous thread of comments
 * @param comment
 */
private void previousComments(final ImgurComment comment){
  if (mIsCommentsAnimating)   return;
  mIsCommentsAnimating=true;
  mSelectedComment=null;
  mCommentAdapter.setSelectedIndex(-1);
  mCommentList.animate().translationX(mCommentList.getWidth()).setDuration(250).setListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      super.onAnimationEnd(animation);
      animation.removeAllListeners();
      if (mPreviousCommentPositionArray.size() <= 1) {
        mCommentList.removeHeaderView(mCommentListHeader);
      }
      mCommentAdapter.clear();
      mCommentAdapter.addItems(mCommentArray.get(comment.getParentId()));
      mCommentArray.remove(comment.getParentId());
      mCommentAdapter.notifyDataSetChanged();
      mCommentList.setSelection(mPreviousCommentPositionArray.get(comment.getParentId()));
      mPreviousCommentPositionArray.remove(comment.getParentId());
      Animator anim=ObjectAnimator.ofFloat(mCommentList,"String_Node_Str",-mCommentList.getWidth(),0);
      anim.addListener(new AnimatorListenerAdapter(){
        @Override public void onAnimationEnd(        Animator animation){
          super.onAnimationEnd(animation);
          animation.removeAllListeners();
          mIsCommentsAnimating=false;
        }
      }
);
      anim.setDuration(250).start();
    }
  }
).start();
}

Fixed version (ground truth):
/** 
 * Changes the comment list to the previous thread of comments
 * @param comment
 */
private void previousComments(final ImgurComment comment){
  final Integer previousSelection=mPreviousCommentPositionArray.get(comment.getParentId());
  if (mIsCommentsAnimating || previousSelection == null) {
    LogUtil.w(TAG,"String_Node_Str");
    return;
  }
  mIsCommentsAnimating=true;
  mSelectedComment=null;
  mCommentAdapter.setSelectedIndex(-1);
  mCommentList.animate().translationX(mCommentList.getWidth()).setDuration(250).setListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      super.onAnimationEnd(animation);
      animation.removeAllListeners();
      if (mPreviousCommentPositionArray.size() <= 1) {
        mCommentList.removeHeaderView(mCommentListHeader);
      }
      mCommentAdapter.clear();
      mCommentAdapter.addItems(mCommentArray.get(comment.getParentId()));
      mCommentArray.remove(comment.getParentId());
      mCommentAdapter.notifyDataSetChanged();
      mCommentList.setSelection(previousSelection);
      mPreviousCommentPositionArray.remove(comment.getParentId());
      Animator anim=ObjectAnimator.ofFloat(mCommentList,"String_Node_Str",-mCommentList.getWidth(),0);
      anim.addListener(new AnimatorListenerAdapter(){
        @Override public void onAnimationEnd(        Animator animation){
          super.onAnimationEnd(animation);
          animation.removeAllListeners();
          mIsCommentsAnimating=false;
        }
      }
);
      anim.setDuration(250).start();
    }
  }
).start();
}
Program: 164518
Project: 164518
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mCommentAdapter != null && !mCommentAdapter.isEmpty()) {
    outState.putParcelableArrayList(KEY_COMMENT,mCommentAdapter.retainItems());
  }
  outState.putBoolean(KEY_LOAD_COMMENTS,mLoadComments);
  outState.putString(KEY_SORT,mCommentSort.getSort());
  if (mPagerAdapter != null && !mPagerAdapter.isEmpty()) {
    outState.putInt(KEY_POSITION,mViewPager.getCurrentItem());
    outState.putParcelableArrayList(KEY_OBJECTS,mPagerAdapter.retainItems());
  }
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mCommentArray.size() > 0) {
    long key=mCommentArray.keyAt(0);
    outState.putParcelableArrayList(KEY_COMMENT,mCommentArray.get(key));
  }
 else   if (!mCommentAdapter.isEmpty()) {
    outState.putParcelableArrayList(KEY_COMMENT,mCommentAdapter.retainItems());
  }
  outState.putBoolean(KEY_LOAD_COMMENTS,mLoadComments);
  outState.putString(KEY_SORT,mCommentSort.getSort());
  if (mPagerAdapter != null && !mPagerAdapter.isEmpty()) {
    outState.putInt(KEY_POSITION,mViewPager.getCurrentItem());
    outState.putParcelableArrayList(KEY_OBJECTS,mPagerAdapter.retainItems());
  }
}
Program: 164520
Project: 164520
Buggy source:
/** 
 * Adds a list of items to the adapter list
 * @param items
 */
public void addItems(List<T> items){
  if (mItems == null) {
    mItems=items;
  }
 else {
    mItems.addAll(items);
  }
  notifyDataSetChanged();
}

Fixed version (ground truth):
/** 
 * Adds a list of items to the adapter list
 * @param items
 */
public void addItems(List<T> items){
  if (items == null || items.isEmpty()) {
    LogUtil.w(TAG,"String_Node_Str");
    return;
  }
  if (mItems == null) {
    mItems=items;
  }
 else {
    mItems.addAll(items);
  }
  notifyDataSetChanged();
}
Program: 164521
Project: 164521
Buggy source:
public void deleteCache(){
  FileUtil.deleteDirectory(mCacheDir);
}

Fixed version (ground truth):
public void deleteCache(){
  FileUtil.deleteDirectory(mCacheDir);
  mCacheDir.mkdirs();
}
Program: 164524
Project: 164524
Buggy source:
@Transactional(readOnly=true) public Pair<List<ExtensionLog>,Integer> getLog(String path,String name,ExtensionLog.Type type,int pageSize,int offset){
  int count=extensionLogRepository.countPages(path,name,type);
  List<ExtensionLog> logs=extensionLogRepository.getPage(path,name,type,pageSize,offset);
  return Pair.of(logs,count);
}

Fixed version (ground truth):
@Transactional(readOnly=true) public Pair<List<ExtensionLog>,Integer> getLog(String path,String name,ExtensionLog.Type type,int pageSize,int offset){
  String typeAsString=type != null ? type.name() : null;
  int count=extensionLogRepository.countPages(path,name,typeAsString);
  List<ExtensionLog> logs=extensionLogRepository.getPage(path,name,typeAsString,pageSize,offset);
  return Pair.of(logs,count);
}
Program: 164525
Project: 164525
Buggy source:
@Query("String_Node_Str" + FIND_EXTENSION_LOG + "String_Node_Str") int countPages(@Bind("String_Node_Str") String path,@Bind("String_Node_Str") String name,@Bind("String_Node_Str") ExtensionLog.Type type);

Fixed version (ground truth):
@Query("String_Node_Str" + FIND_EXTENSION_LOG + "String_Node_Str") int countPages(@Bind("String_Node_Str") String path,@Bind("String_Node_Str") String name,@Bind("String_Node_Str") String type);
Program: 164526
Project: 164526
Buggy source:
@Query("String_Node_Str" + FIND_EXTENSION_LOG + "String_Node_Str") List<ExtensionLog> getPage(@Bind("String_Node_Str") String path,@Bind("String_Node_Str") String name,@Bind("String_Node_Str") ExtensionLog.Type type,@Bind("String_Node_Str") int pageSize,@Bind("String_Node_Str") int offset);

Fixed version (ground truth):
@Query("String_Node_Str" + FIND_EXTENSION_LOG + "String_Node_Str") List<ExtensionLog> getPage(@Bind("String_Node_Str") String path,@Bind("String_Node_Str") String name,@Bind("String_Node_Str") String type,@Bind("String_Node_Str") int pageSize,@Bind("String_Node_Str") int offset);
Program: 164528
Project: 164528
Buggy source:
private List<ScriptPathNameHash> getActiveScriptsForEvent(String event,String basePath,boolean async){
  Set<String> paths=new TreeSet<>();
  int basePathLength=basePath.length();
  for (int i=1; i < basePathLength; i++) {
    if (basePath.charAt(i) == '.') {
      paths.add(basePath.substring(0,i));
    }
  }
  paths.add("String_Node_Str");
  paths.add(basePath);
  return extensionRepository.findActive(paths,async,event);
}

Fixed version (ground truth):
private List<ScriptPathNameHash> getActiveScriptsForEvent(String event,String basePath,boolean async){
  Set<String> paths=new TreeSet<>();
  int basePathLength=basePath.length();
  for (int i=1; i < basePathLength; i++) {
    if (basePath.charAt(i) == '-') {
      paths.add(basePath.substring(0,i));
    }
  }
  paths.add("String_Node_Str");
  paths.add(basePath);
  return extensionRepository.findActive(paths,async,event);
}
Program: 164529
Project: 164529
Buggy source:
public <T>T executeScriptsForEvent(String event,String basePath,Map<String,Object> payload,Class<T> clazz){
  List<ScriptPathNameHash> activePaths=getActiveScriptsForEvent(event,basePath,false);
  T res=null;
  Map<String,Object> input=new HashMap<>(payload);
  input.put("String_Node_Str",event);
  for (  ScriptPathNameHash activePath : activePaths) {
    String path=activePath.getPath();
    String name=activePath.getName();
    res=scriptingExecutionService.executeScript(path,name,activePath.getHash(),() -> getScript(path,name) + "String_Node_Str",input,clazz);
    input.put("String_Node_Str",res);
  }
  return res;
}

Fixed version (ground truth):
public <T>T executeScriptsForEvent(String event,String basePath,Map<String,Object> payload,Class<T> clazz){
  List<ScriptPathNameHash> activePaths=getActiveScriptsForEvent(event,basePath,false);
  T res=null;
  Map<String,Object> input=new HashMap<>(payload);
  input.put("String_Node_Str",event);
  for (  ScriptPathNameHash activePath : activePaths) {
    String path=activePath.getPath();
    String name=activePath.getName();
    res=scriptingExecutionService.executeScript(name,activePath.getHash(),() -> getScript(path,name) + "String_Node_Str",input,clazz);
    input.put("String_Node_Str",res);
  }
  return res;
}
Program: 164530
Project: 164530
Buggy source:
public void executeScriptAsync(String path,String name,String hash,Supplier<String> scriptFetcher,Map<String,Object> params){
  Optional.ofNullable(asyncExecutors.get(path,(key) -> Executors.newSingleThreadExecutor())).ifPresent(it -> it.submit(() -> {
    executeScript(path,name,hash,scriptFetcher,params,Object.class);
  }
));
}

Fixed version (ground truth):
public void executeScriptAsync(String path,String name,String hash,Supplier<String> scriptFetcher,Map<String,Object> params){
  Optional.ofNullable(asyncExecutors.get(path,(key) -> Executors.newSingleThreadExecutor())).ifPresent(it -> it.submit(() -> {
    executeScript(name,hash,scriptFetcher,params,Object.class);
  }
));
}