nus-yam/ex-repair huggingface dataset:
Program: 43883
Project: 43883
Buggy source:
private void setData(ViewGroup view,int position){
  TextView route=(TextView)view.findViewById(R.id.route);
  TextView destination=(TextView)view.findViewById(R.id.destination);
  TextView time=(TextView)view.findViewById(R.id.time);
  TextView status=(TextView)view.findViewById(R.id.status);
  TextView etaView=(TextView)view.findViewById(R.id.eta);
  final StopInfo stopInfo=mInfo.get(position);
  final ObaArrivalInfo arrivalInfo=stopInfo.getInfo();
  route.setText(arrivalInfo.getShortName());
  destination.setText(arrivalInfo.getHeadsign());
  status.setText(stopInfo.getStatusText());
  long eta=stopInfo.getEta();
  if (eta == 0) {
    etaView.setText(R.string.stop_info_eta_now);
  }
 else {
    etaView.setText(String.valueOf(eta));
  }
  int color=getResources().getColor(stopInfo.getColor());
  etaView.setTextColor(color);
  time.setText(DateUtils.formatDateTime(StopInfoActivity.this,stopInfo.getDisplayTime(),DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT));
  ContentValues values=mTripsForStop.getValues(arrivalInfo.getTripId());
  if (values != null) {
    String tripName=values.getAsString(ObaContract.Trips.NAME);
    TextView tripInfo=(TextView)view.findViewById(R.id.trip_info);
    if (tripName.length() == 0) {
      tripName=getString(R.string.trip_info_noname);
    }
    tripInfo.setText(tripName);
    tripInfo.setVisibility(View.VISIBLE);
  }
 else {
    View tripInfo=view.findViewById(R.id.trip_info);
    tripInfo.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
private void setData(ViewGroup view,int position){
  TextView route=(TextView)view.findViewById(R.id.route);
  TextView destination=(TextView)view.findViewById(R.id.destination);
  TextView time=(TextView)view.findViewById(R.id.time);
  TextView status=(TextView)view.findViewById(R.id.status);
  TextView etaView=(TextView)view.findViewById(R.id.eta);
  final StopInfo stopInfo=mInfo.get(position);
  final ObaArrivalInfo arrivalInfo=stopInfo.getInfo();
  route.setText(arrivalInfo.getShortName());
  destination.setText(MyTextUtils.toTitleCase(arrivalInfo.getHeadsign()));
  status.setText(stopInfo.getStatusText());
  long eta=stopInfo.getEta();
  if (eta == 0) {
    etaView.setText(R.string.stop_info_eta_now);
  }
 else {
    etaView.setText(String.valueOf(eta));
  }
  int color=getResources().getColor(stopInfo.getColor());
  etaView.setTextColor(color);
  time.setText(DateUtils.formatDateTime(StopInfoActivity.this,stopInfo.getDisplayTime(),DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT));
  ContentValues values=mTripsForStop.getValues(arrivalInfo.getTripId());
  if (values != null) {
    String tripName=values.getAsString(ObaContract.Trips.NAME);
    TextView tripInfo=(TextView)view.findViewById(R.id.trip_info);
    if (tripName.length() == 0) {
      tripName=getString(R.string.trip_info_noname);
    }
    tripInfo.setText(tripName);
    tripInfo.setVisibility(View.VISIBLE);
  }
 else {
    View tripInfo=view.findViewById(R.id.trip_info);
    tripInfo.setVisibility(View.GONE);
  }
}
Program: 43884
Project: 43884
Buggy source:
/** 
 * This should be used with compound drawables
 */
public void setView2(TextView nameView,String stopId,String stopName){
  ContentValues values=mMap.getValues(stopId);
  int icon=0;
  if (values != null) {
    Integer i=values.getAsInteger(ObaContract.Stops.FAVORITE);
    final boolean favorite=(i != null) && (i == 1);
    final String userName=values.getAsString(ObaContract.Stops.USER_NAME);
    nameView.setText(TextUtils.isEmpty(userName) ? stopName : userName);
    icon=favorite ? R.drawable.star_on : 0;
  }
 else {
    nameView.setText(stopName);
  }
  nameView.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0);
}

Fixed version (ground truth):
/** 
 * This should be used with compound drawables
 */
public void setView2(TextView nameView,String stopId,String stopName){
  ContentValues values=mMap.getValues(stopId);
  int icon=0;
  if (values != null) {
    Integer i=values.getAsInteger(ObaContract.Stops.FAVORITE);
    final boolean favorite=(i != null) && (i == 1);
    final String userName=values.getAsString(ObaContract.Stops.USER_NAME);
    nameView.setText(TextUtils.isEmpty(userName) ? MyTextUtils.toTitleCase(stopName) : userName);
    icon=favorite ? R.drawable.star_on : 0;
  }
 else {
    nameView.setText(MyTextUtils.toTitleCase(stopName));
  }
  nameView.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0);
}
Program: 43885
Project: 43885
Buggy source:
private String getAppUid(){
  final TelephonyManager telephony=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
  final String id=telephony.getDeviceId();
  try {
    MessageDigest digest=MessageDigest.getInstance("String_Node_Str");
    digest.update(id.getBytes());
    return getHex(digest.digest());
  }
 catch (  NoSuchAlgorithmException e) {
    return UUID.randomUUID().toString();
  }
}

Fixed version (ground truth):
private String getAppUid(){
  try {
    final TelephonyManager telephony=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    final String id=telephony.getDeviceId();
    MessageDigest digest=MessageDigest.getInstance("String_Node_Str");
    digest.update(id.getBytes());
    return getHex(digest.digest());
  }
 catch (  Exception e) {
    return UUID.randomUUID().toString();
  }
}
Program: 43886
Project: 43886
Buggy source:
private void startTask(){
  Log.d(TAG,"String_Node_Str" + mCurrentRequest);
  mTask=new AsyncTask(mCurrentRequest);
  mTask.execute();
}

Fixed version (ground truth):
private void startTask(){
  Log.d(TAG,"String_Node_Str" + mCurrentRequest);
  if (mCurrentRequest != null) {
    mTask=new MyTask();
    mTask.execute(mCurrentRequest);
  }
}
Program: 43887
Project: 43887
Buggy source:
@Override protected ObaResponse doInBackground(String... params){
  if (mInfo.getRouteId() != null) {
    return ObaApi.getStopsForRoute(mActivity,mInfo.getRouteId(),false);
  }
 else {
    return ObaApi.getStopsByLocation(mActivity,mInfo.getCenter(),0,mInfo.getLatSpan(),mInfo.getLonSpan(),null,0);
  }
}

Fixed version (ground truth):
@Override protected ResponseInfo doInBackground(RequestInfo... params){
  final RequestInfo info=params[0];
  ObaResponse response=null;
  if (info.getRouteId() != null) {
    response=ObaApi.getStopsForRoute(mActivity,info.getRouteId(),false);
  }
 else {
    response=ObaApi.getStopsByLocation(mActivity,info.getCenter(),0,info.getLatSpan(),info.getLonSpan(),null,0);
  }
  return new ResponseInfo(info,response);
}
Program: 43888
Project: 43888
Buggy source:
void setRefreshError(){
  TextView errorText=(TextView)mResponseError.findViewById(R.id.response_error_text);
  CharSequence relativeTime=DateUtils.getRelativeTimeSpanString(mResponseTime,System.currentTimeMillis(),DateUtils.MINUTE_IN_MILLIS,0);
  errorText.setText(getString(R.string.stop_info_old_data,relativeTime));
  mResponseError.setVisibility(View.VISIBLE);
  mEmptyText.setText(R.string.stop_info_nodata);
  ((BaseAdapter)getListAdapter()).notifyDataSetChanged();
  mLoadingProgress.hideLoading();
  setProgressBarIndeterminateVisibility(false);
}

Fixed version (ground truth):
void setRefreshError(){
  final long now=System.currentTimeMillis();
  if ((now - mResponseTime) >= 2 * DateUtils.MINUTE_IN_MILLIS) {
    TextView errorText=(TextView)mResponseError.findViewById(R.id.response_error_text);
    CharSequence relativeTime=DateUtils.getRelativeTimeSpanString(mResponseTime,now,DateUtils.MINUTE_IN_MILLIS,0);
    errorText.setText(getString(R.string.stop_info_old_data,relativeTime));
    mResponseError.setVisibility(View.VISIBLE);
    mEmptyText.setText(R.string.stop_info_nodata);
  }
 else {
    mResponseError.setVisibility(View.GONE);
  }
  StopInfoListAdapter adapter=(StopInfoListAdapter)getListView().getAdapter();
  adapter.setData(mResponse.getData().getArrivalsAndDepartures());
  mLoadingProgress.hideLoading();
  setProgressBarIndeterminateVisibility(false);
}
Program: 43889
Project: 43889
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.route_info);
  registerForContextMenu(getExpandableListView());
  Bundle bundle=getIntent().getExtras();
  mRouteId=bundle.getString(ROUTE_ID);
  setListAdapter(new SimpleExpandableListAdapter(this,new ArrayList<HashMap<String,String>>(),android.R.layout.simple_expandable_list_item_1,new String[]{"String_Node_Str"},new int[]{android.R.id.text1},new ArrayList<ArrayList<HashMap<String,String>>>(),0,null,new int[]{}));
  Object config=getLastNonConfigurationInstance();
  if (config != null) {
    Object[] results=(Object[])config;
    setHeader((ObaResponse)results[0],false);
    setStopsForRoute((StopsForRouteInfo)results[1]);
  }
 else {
    mRouteInfoTask=new GetRouteInfo().execute(mRouteId);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.route_info);
  registerForContextMenu(getExpandableListView());
  final Intent intent=getIntent();
  final Bundle bundle=intent.getExtras();
  final Uri data=intent.getData();
  if (data != null) {
    mRouteId=data.getLastPathSegment();
  }
 else   if (bundle != null) {
    mRouteId=bundle.getString(ROUTE_ID);
  }
 else {
    Log.e(TAG,"String_Node_Str");
    finish();
    return;
  }
  setListAdapter(new SimpleExpandableListAdapter(this,new ArrayList<HashMap<String,String>>(),android.R.layout.simple_expandable_list_item_1,new String[]{"String_Node_Str"},new int[]{android.R.id.text1},new ArrayList<ArrayList<HashMap<String,String>>>(),0,null,new int[]{}));
  Object config=getLastNonConfigurationInstance();
  if (config != null) {
    Object[] results=(Object[])config;
    setHeader((ObaResponse)results[0],false);
    setStopsForRoute((StopsForRouteInfo)results[1]);
  }
 else {
    mRouteInfoTask=new GetRouteInfo().execute(mRouteId);
  }
}
Program: 43890
Project: 43890
Buggy source:
public static Intent makeIntent(Context context,String routeId){
  Intent myIntent=new Intent(context,RouteInfoActivity.class);
  myIntent.putExtra(ROUTE_ID,routeId);
  return myIntent;
}

Fixed version (ground truth):
public static Intent makeIntent(Context context,String routeId){
  Intent myIntent=new Intent(context,RouteInfoActivity.class);
  myIntent.setData(Uri.withAppendedPath(ObaContract.Routes.CONTENT_URI,routeId));
  return myIntent;
}
Program: 43891
Project: 43891
Buggy source:
public static Intent makeIntent(Context context,ObaStop stop){
  Intent myIntent=new Intent(context,StopInfoActivity.class);
  myIntent.putExtra(STOP_ID,stop.getId());
  myIntent.putExtra(STOP_NAME,stop.getName());
  myIntent.putExtra(STOP_DIRECTION,stop.getDirection());
  return myIntent;
}

Fixed version (ground truth):
public static Intent makeIntent(Context context,ObaStop stop){
  Intent myIntent=new Intent(context,StopInfoActivity.class);
  myIntent.setData(Uri.withAppendedPath(ObaContract.Stops.CONTENT_URI,stop.getId()));
  myIntent.putExtra(STOP_NAME,stop.getName());
  myIntent.putExtra(STOP_DIRECTION,stop.getDirection());
  return myIntent;
}
Program: 43892
Project: 43892
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.stop_info);
  setListAdapter(new StopInfoListAdapter());
  Bundle bundle=getIntent().getExtras();
  mStopId=bundle.getString(STOP_ID);
  setHeader(bundle);
  UIHelp.setChildClickable(this,R.id.show_all,mShowAllClick);
  mRoutesFilter=ObaContract.StopRouteFilters.get(this,mStopId);
  mTripsForStop=getTripsForStop();
  Object response=getLastNonConfigurationInstance();
  if (response != null) {
    setResponse((ObaResponse)response,false);
  }
 else {
    getStopInfo(false);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.stop_info);
  setListAdapter(new StopInfoListAdapter());
  final Intent intent=getIntent();
  final Bundle bundle=intent.getExtras();
  final Uri data=intent.getData();
  if (data != null) {
    mStopId=data.getLastPathSegment();
  }
 else   if (bundle != null) {
    mStopId=bundle.getString(STOP_ID);
  }
 else {
    Log.e(TAG,"String_Node_Str");
    finish();
    return;
  }
  setHeader(bundle);
  UIHelp.setChildClickable(this,R.id.show_all,mShowAllClick);
  mRoutesFilter=ObaContract.StopRouteFilters.get(this,mStopId);
  mTripsForStop=getTripsForStop();
  Object response=getLastNonConfigurationInstance();
  if (response != null) {
    setResponse((ObaResponse)response,false);
  }
 else {
    getStopInfo(false);
  }
}
Program: 43893
Project: 43893
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.trip_info);
  final Bundle bundle=getIntent().getExtras();
  if (bundle == null) {
    Log.e(TAG,"String_Node_Str");
    finish();
    return;
  }
  if (!initFromBundle(bundle)) {
    Log.e(TAG,"String_Node_Str");
    finish();
    return;
  }
  boolean newTrip=!initFromDB();
  initForm(newTrip);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.trip_info);
  if (!initFromIntent(getIntent())) {
    Log.e(TAG,"String_Node_Str");
    finish();
    return;
  }
  boolean newTrip=!initFromDB();
  initForm(newTrip);
}
Program: 43894
Project: 43894
Buggy source:
public static void start(Context context,String tripId,String stopId,String routeId,String routeName,String stopName,long departureTime,String headsign){
  Intent myIntent=new Intent(context,TripInfoActivity.class);
  myIntent.putExtra(TRIP_ID,tripId);
  myIntent.putExtra(STOP_ID,stopId);
  myIntent.putExtra(ROUTE_ID,routeId);
  myIntent.putExtra(ROUTE_NAME,routeName);
  myIntent.putExtra(STOP_NAME,stopName);
  myIntent.putExtra(DEPARTURE_TIME,departureTime);
  myIntent.putExtra(HEADSIGN,headsign);
  context.startActivity(myIntent);
}

Fixed version (ground truth):
public static void start(Context context,String tripId,String stopId,String routeId,String routeName,String stopName,long departureTime,String headsign){
  Intent myIntent=new Intent(context,TripInfoActivity.class);
  myIntent.setData(ObaContract.Trips.buildUri(tripId,stopId));
  myIntent.putExtra(ROUTE_ID,routeId);
  myIntent.putExtra(ROUTE_NAME,routeName);
  myIntent.putExtra(STOP_NAME,stopName);
  myIntent.putExtra(DEPARTURE_TIME,departureTime);
  myIntent.putExtra(HEADSIGN,headsign);
  context.startActivity(myIntent);
}
Program: 43895
Project: 43895
Buggy source:
final void scheduleNext(TripsDbAdapter adapter,Cursor c){
  final int days=c.getInt(TripsDbAdapter.TRIP_COL_DAYS);
  if (days == 0) {
    adapter.deleteTrip(mTripId,mStopId);
  }
 else {
    final Intent tripService=new Intent(TripService.this,TripService.class);
    tripService.setAction(TripService.ACTION_SCHEDULE_TRIP);
    tripService.setData(buildTripUri(mTripId,mStopId));
    TripService.this.startService(tripService);
  }
}

Fixed version (ground truth):
final void scheduleNext(TripsDbAdapter adapter,Cursor c){
  final int days=c.getInt(TripsDbAdapter.TRIP_COL_DAYS);
  if (days == 0) {
    adapter.deleteTrip(mTripId,mStopId);
  }
 else {
    TripService ctx=TripService.this;
    Intent myIntent=new Intent(ACTION_POLL_TRIP,buildTripUri(mTripId,mStopId),ctx,AlarmReceiver.class);
    PendingIntent alarmIntent=PendingIntent.getBroadcast(ctx,0,myIntent,PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarm=(AlarmManager)ctx.getSystemService(Context.ALARM_SERVICE);
    long triggerTime=System.currentTimeMillis() + 60 * ONE_MINUTE;
    alarm.set(AlarmManager.RTC_WAKEUP,triggerTime,alarmIntent);
  }
}
Program: 43896
Project: 43896
Buggy source:
synchronized void clearNotification(){
  Log.d(TAG,"String_Node_Str" + getTaskId());
  mState=CLEARED;
}

Fixed version (ground truth):
synchronized void clearNotification(){
  Log.d(TAG,"String_Node_Str" + getTaskId());
  mNotification=null;
  mState=DONE;
}
Program: 43897
Project: 43897
Buggy source:
final boolean doPoll(Cursor c){
  final String tripId=mTripId;
  final String stopId=mStopId;
  final long reminderMS=(1 + c.getInt(TripsDbAdapter.TRIP_COL_REMINDER)) * ONE_MINUTE;
  final long departMS=c.getInt(TripsDbAdapter.TRIP_COL_DEPARTURE) * ONE_MINUTE;
  mState=NOT_FOUND;
  while (mState != CLEARED) {
    Log.d(TAG,"String_Node_Str" + getTaskId());
    ObaResponse response=ObaApi.getArrivalsDeparturesForStop(stopId);
    final long now=System.currentTimeMillis();
    if (response.getCode() == ObaApi.OBA_OK) {
      final ObaArray arrivals=response.getData().getArrivalsAndDepartures();
      final int length=arrivals.length();
      for (int i=0; i < length; ++i) {
        ObaArrivalInfo info=arrivals.getArrivalInfo(i);
        if (tripId.equals(info.getTripId())) {
synchronized (this) {
            if (mState == NOT_FOUND) {
              Log.d(TAG,"String_Node_Str" + getTaskId());
              mState=FOUND;
            }
            long time=info.getPredictedArrivalTime();
            if (time == 0) {
              time=info.getScheduledArrivalTime();
            }
            if (mState == FOUND) {
              if ((time - reminderMS) < now) {
                doNotification(time - now,c);
                mState=NOTIFIED;
              }
 else               if (time < now) {
                mState=CLEARED;
                break;
              }
            }
 else             if (mState == NOTIFIED) {
              final long timeDiff=time - now;
              if (timeDiff <= 0) {
                cancelNotification();
                mState=CLEARED;
                break;
              }
 else {
                doNotification(timeDiff,c);
              }
            }
          }
        }
      }
    }
    if (mState == NOT_FOUND && ((departMS + LOOKAHEAD_DURATION_MS) > now)) {
      Log.d(TAG,"String_Node_Str" + getTaskId());
      break;
    }
    try {
      Thread.sleep(30 * 1000);
    }
 catch (    InterruptedException e) {
    }
  }
  return mState == CLEARED;
}

Fixed version (ground truth):
final void doPoll(Cursor c){
  final String stopId=mStopId;
  final long reminderMS=(1 + c.getInt(TripsDbAdapter.TRIP_COL_REMINDER)) * ONE_MINUTE;
  final long departMS=c.getInt(TripsDbAdapter.TRIP_COL_DEPARTURE) * ONE_MINUTE;
  mState=NOT_FOUND;
  while (mState != DONE) {
    Log.d(TAG,"String_Node_Str" + getTaskId());
    ObaResponse response=ObaApi.getArrivalsDeparturesForStop(stopId);
synchronized (this) {
      if (mState == DONE) {
        break;
      }
      final long now=System.currentTimeMillis();
      if (response.getCode() == ObaApi.OBA_OK) {
        if (checkArrivals(response,c,reminderMS,now)) {
          break;
        }
      }
      if (mState == NOT_FOUND && ((departMS + LOOKAHEAD_DURATION_MS) > now)) {
        Log.d(TAG,"String_Node_Str" + getTaskId());
        mState=DONE;
        break;
      }
    }
    try {
      Thread.sleep(30 * 1000);
    }
 catch (    InterruptedException e) {
    }
  }
}
Program: 43898
Project: 43898
Buggy source:
final void doNotification(long timeDiff,Cursor c){
  final Context ctx=TripService.this;
  Log.d(TAG,"String_Node_Str" + getTaskId());
  if (mNotification == null) {
    mNotification=new Notification(R.drawable.stat_trip,null,System.currentTimeMillis());
    mNotification.defaults|=Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;
    Intent deleteIntent=new Intent(ctx,TripService.class);
    deleteIntent.setAction(ACTION_CANCEL_POLL);
    deleteIntent.setData(buildTripUri(mTripId,mStopId));
    mNotification.deleteIntent=PendingIntent.getService(ctx,0,deleteIntent,PendingIntent.FLAG_ONE_SHOT);
    Intent stopActivity=new Intent(ctx,StopInfoActivity.class);
    stopActivity.putExtra(StopInfoActivity.STOP_ID,mStopId);
    mNotificationIntent=PendingIntent.getActivity(ctx,0,stopActivity,PendingIntent.FLAG_ONE_SHOT);
  }
 else {
    mNotification.defaults=0;
  }
  final String title=getResources().getString(R.string.app_name);
  mNotification.setLatestEventInfo(ctx,title,getNotifyText(c,timeDiff),mNotificationIntent);
  NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  nm.notify(NOTIFY_ID,mNotification);
}

Fixed version (ground truth):
final void doNotification(long timeDiff,Cursor c){
  final Context ctx=TripService.this;
  if (mNotification == null) {
    Log.d(TAG,"String_Node_Str" + getTaskId());
    mNotification=new Notification(R.drawable.stat_trip,null,System.currentTimeMillis());
    mNotification.defaults|=Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;
    Intent deleteIntent=new Intent(ctx,TripService.class);
    deleteIntent.setAction(ACTION_CANCEL_POLL);
    deleteIntent.setData(buildTripUri(mTripId,mStopId));
    mNotification.deleteIntent=PendingIntent.getService(ctx,0,deleteIntent,PendingIntent.FLAG_ONE_SHOT);
    Intent stopActivity=new Intent(ctx,StopInfoActivity.class);
    stopActivity.putExtra(StopInfoActivity.STOP_ID,mStopId);
    mNotificationIntent=PendingIntent.getActivity(ctx,0,stopActivity,PendingIntent.FLAG_ONE_SHOT);
  }
 else {
    Log.d(TAG,"String_Node_Str" + getTaskId());
    mNotification.defaults=0;
  }
  final String title=getResources().getString(R.string.app_name);
  mNotification.setLatestEventInfo(ctx,title,getNotifyText(c,timeDiff),mNotificationIntent);
  NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  nm.notify(NOTIFY_ID,mNotification);
}
Program: 43899
Project: 43899
Buggy source:
final String getNotifyText(Cursor c,long timeDiff){
  final String routeName=RoutesDbAdapter.getRouteShortName(this,c.getString(TripsDbAdapter.TRIP_COL_ROUTEID));
  final Resources res=getResources();
  if (timeDiff < ONE_MINUTE) {
    final String fmt=res.getString(R.string.trip_stat_lessthanone);
    return String.format(fmt,routeName);
  }
 else   if (timeDiff < ONE_MINUTE * 2) {
    final String fmt=res.getString(R.string.trip_stat_one);
    return String.format(fmt,routeName);
  }
 else {
    final String fmt=res.getString(R.string.trip_stat);
    return String.format(fmt,routeName,(int)(timeDiff / ONE_MINUTE));
  }
}

Fixed version (ground truth):
final String getNotifyText(Cursor c,long timeDiff){
  final String routeName=RoutesDbAdapter.getRouteShortName(this,c.getString(TripsDbAdapter.TRIP_COL_ROUTEID));
  final Resources res=getResources();
  if (timeDiff <= 0) {
    final String fmt=res.getString(R.string.trip_stat_gone);
    return String.format(fmt,routeName);
  }
 else   if (timeDiff < ONE_MINUTE) {
    final String fmt=res.getString(R.string.trip_stat_lessthanone);
    return String.format(fmt,routeName);
  }
 else   if (timeDiff < ONE_MINUTE * 2) {
    final String fmt=res.getString(R.string.trip_stat_one);
    return String.format(fmt,routeName);
  }
 else {
    final String fmt=res.getString(R.string.trip_stat);
    return String.format(fmt,routeName,(int)(timeDiff / ONE_MINUTE));
  }
}
Program: 43900
Project: 43900
Buggy source:
@Override public void onPause(){
  mTimer.cancel();
  super.onPause();
}

Fixed version (ground truth):
@Override public void onPause(){
  mTimer.cancel();
  mTimer=null;
  super.onPause();
}
Program: 43901
Project: 43901
Buggy source:
@Override public void onResume(){
  mTimer.schedule(new TimerTask(){
    @Override public void run(){
      mRefreshHandler.post(mRefresh);
    }
  }
,RefreshPeriod,RefreshPeriod);
  super.onResume();
}

Fixed version (ground truth):
@Override public void onResume(){
  if (mTimer == null) {
    mTimer=new Timer();
  }
  mTimer.schedule(new TimerTask(){
    @Override public void run(){
      mRefreshHandler.post(mRefresh);
    }
  }
,RefreshPeriod,RefreshPeriod);
  super.onResume();
}
Program: 43902
Project: 43902
Buggy source:
/** 
 * @param connector JMX connector
 * @param url JMX service URL object
 * @param displayUrl The URL user manually input
 */
ConnectionImpl(JMXConnector connector,JMXServiceURL url){
  Validate.notNull(connector,"String_Node_Str");
  Validate.notNull(url,"String_Node_Str");
  this.connector=connector;
  this.url=url;
}

Fixed version (ground truth):
/** 
 * @param connector JMX connector
 * @param url JMX service URL object
 */
ConnectionImpl(JMXConnector connector,JMXServiceURL url){
  Validate.notNull(connector,"String_Node_Str");
  Validate.notNull(url,"String_Node_Str");
  this.connector=connector;
  this.url=url;
}
Program: 43903
Project: 43903
Buggy source:
/** 
 * @param connector JMX connector
 * @param url JMX service URL object
 * @param displayUrl The URL user manually input
 */
ConnectionImpl(JMXConnector connector,JMXServiceURL url){
  Validate.notNull(connector,"String_Node_Str");
  Validate.notNull(url,"String_Node_Str");
  this.connector=connector;
  this.url=url;
}

Fixed version (ground truth):
/** 
 * @param connector JMX connector
 * @param url JMX service URL object
 */
ConnectionImpl(JMXConnector connector,JMXServiceURL url){
  Validate.notNull(connector,"String_Node_Str");
  Validate.notNull(url,"String_Node_Str");
  this.connector=connector;
  this.url=url;
}
Program: 43904
Project: 43904
Buggy source:
/** 
 * Get full MBean name with given bean name, domain and session
 * @param bean Name of bean. It can be NULL so that session#getBean() is returned
 * @param domain Domain for bean
 * @param session Current session
 * @return Full qualified name of MBean
 * @throws JMException Thrown when given MBean name is malformed
 * @throws IOException
 */
public static String getBeanName(String bean,String domain,Session session) throws JMException, IOException {
  Validate.notNull(session,"String_Node_Str");
  if (bean == null) {
    return session.getBean();
  }
  if (SyntaxUtils.isNull(bean)) {
    return null;
  }
  MBeanServerConnection con=session.getConnection().getServerConnection();
  if (PATTERN_BEAN_NAME.matcher(bean).find()) {
    ObjectName name=new ObjectName(bean);
    con.getMBeanInfo(name);
    return bean;
  }
  String domainName=DomainCommand.getDomainName(domain,session);
  if (domainName == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (PATTERN_PROPERTIES.matcher(bean).find()) {
    return domainName + "String_Node_Str" + bean;
  }
  throw new IllegalArgumentException("String_Node_Str" + bean + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get full MBean name with given bean name, domain and session
 * @param bean Name of bean. It can be NULL so that session#getBean() is returned
 * @param domain Domain for bean
 * @param session Current session
 * @return Full qualified name of MBean
 * @throws JMException Thrown when given MBean name is malformed
 * @throws IOException
 */
public static String getBeanName(String bean,String domain,Session session) throws JMException, IOException {
  Validate.notNull(session,"String_Node_Str");
  if (bean == null) {
    return session.getBean();
  }
  if (SyntaxUtils.isNull(bean)) {
    return null;
  }
  MBeanServerConnection con=session.getConnection().getServerConnection();
  if (bean.indexOf(':') != -1) {
    try {
      ObjectName name=new ObjectName(bean);
      con.getMBeanInfo(name);
      return bean;
    }
 catch (    MalformedObjectNameException e) {
    }
catch (    InstanceNotFoundException e) {
    }
  }
  String domainName=DomainCommand.getDomainName(domain,session);
  if (domainName == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    ObjectName name=new ObjectName(domainName + "String_Node_Str" + bean);
    con.getMBeanInfo(name);
    return domainName + "String_Node_Str" + bean;
  }
 catch (  MalformedObjectNameException e) {
  }
catch (  InstanceNotFoundException e) {
  }
  throw new IllegalArgumentException("String_Node_Str" + bean + "String_Node_Str");
}
Program: 43905
Project: 43905
Buggy source:
private void getAttributeAndVerify(final String domain,String bean,final String attribute,final String expectedBean,final Object expectedValue){
  command.setDomain(domain);
  command.setBean(bean);
  command.setAttributes(Arrays.asList(attribute));
  command.setSimpleFormat(true);
  final MBeanServerConnection con=context.mock(MBeanServerConnection.class);
  final MBeanInfo beanInfo=context.mock(MBeanInfo.class);
  final MBeanAttributeInfo attributeInfo=context.mock(MBeanAttributeInfo.class);
  try {
    context.checking(new Expectations(){
{
        one(con).getDomains();
        will(returnValue(new String[]{domain,RandomStringUtils.randomAlphabetic(5)}));
        one(con).getMBeanInfo(new ObjectName(expectedBean));
        will(returnValue(beanInfo));
        one(beanInfo).getAttributes();
        will(returnValue(new MBeanAttributeInfo[]{attributeInfo}));
        allowing(attributeInfo).getName();
        will(returnValue(attribute));
        allowing(attributeInfo).isReadable();
        will(returnValue(true));
        one(con).getAttribute(new ObjectName(expectedBean),attribute);
        will(returnValue(expectedValue));
      }
    }
);
    command.setSession(new MockSession(output,con));
    command.execute();
    context.assertIsSatisfied();
    assertEquals(expectedValue.toString(),output.toString().trim());
  }
 catch (  JMException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
catch (  IOException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void getAttributeAndVerify(final String domain,String bean,final String attribute,final String expectedBean,final Object expectedValue){
  command.setDomain(domain);
  command.setBean(bean);
  command.setAttributes(Arrays.asList(attribute));
  command.setSimpleFormat(true);
  final MBeanServerConnection con=context.mock(MBeanServerConnection.class);
  final MBeanInfo beanInfo=context.mock(MBeanInfo.class);
  final MBeanAttributeInfo attributeInfo=context.mock(MBeanAttributeInfo.class);
  try {
    context.checking(new Expectations(){
{
        one(con).getDomains();
        will(returnValue(new String[]{domain,RandomStringUtils.randomAlphabetic(5)}));
        allowing(con).getMBeanInfo(new ObjectName(expectedBean));
        will(returnValue(beanInfo));
        one(beanInfo).getAttributes();
        will(returnValue(new MBeanAttributeInfo[]{attributeInfo}));
        allowing(attributeInfo).getName();
        will(returnValue(attribute));
        allowing(attributeInfo).isReadable();
        will(returnValue(true));
        one(con).getAttribute(new ObjectName(expectedBean),attribute);
        will(returnValue(expectedValue));
      }
    }
);
    command.setSession(new MockSession(output,con));
    command.execute();
    context.assertIsSatisfied();
    assertEquals(expectedValue.toString(),output.toString().trim());
  }
 catch (  JMException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
catch (  IOException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}
Program: 43906
Project: 43906
Buggy source:
private void schedulePendingTasks(){
  Map<String,Method> tasks=pendingTasks.all();
  for (  Map.Entry<String,Method> task : tasks.entrySet()) {
    Method method=task.getValue();
    Class<?> controller=method.getDeclaringClass();
    String URI=linker.linkTo(controller,method);
    try {
      Trigger trigger=builder.triggerFor(controller,method);
      trigger.getJobDataMap().put("String_Node_Str",URI);
      scheduler.schedule(DefaultRequestScopedTask.class,trigger,task.getKey());
      pendingTasks.remove(task.getKey());
    }
 catch (    ParseException e) {
      log.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void schedulePendingTasks(){
  Iterator<Entry<String,Method>> tasks=pendingTasks.iterator();
  while (tasks.hasNext()) {
    Entry<String,Method> task=tasks.next();
    Method method=task.getValue();
    Class<?> controller=method.getDeclaringClass();
    String URI=linker.linkTo(controller,method);
    try {
      Trigger trigger=builder.triggerFor(controller,method);
      trigger.getJobDataMap().put("String_Node_Str",URI);
      scheduler.schedule(DefaultRequestScopedTask.class,trigger,task.getKey());
      tasks.remove();
    }
 catch (    ParseException e) {
      log.error("String_Node_Str",e);
    }
  }
}
Program: 43907
Project: 43907
Buggy source:
@PostConstruct public void start(){
  try {
    this.scheduler.start();
  }
 catch (  SchedulerException e) {
    logger.debug("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Calls {#start()} after the indicated number of seconds. (This call does not block).  This can be useful within applications that have initializers that create the scheduler immediately,  before the resources needed by the executing jobs have been fully initialized.
 */
@PostConstruct public void start(){
  try {
    this.scheduler.startDelayed(5);
  }
 catch (  SchedulerException e) {
    logger.debug("String_Node_Str",e);
  }
}
Program: 43908
Project: 43908
Buggy source:
/** 
 * Change NullSocket to: class NullSocket extends Socket { private final byte[] buffer = new byte[50];
 * @Override public InputStream getInputStream() { return new ByteArrayInputStream(this.buffer); }
 * @Override public OutputStream getOutputStream() { return new ByteArrayOutputStream(10); } }
 */
@Override public void onDisable(){
  for (  UUID uuid : tagged.keySet()) {
    Player plr=Bukkit.getPlayer(uuid);
    NPC npc=npcm.getNPC(plr.getUniqueId());
    if (npc != null) {
      if (isDebugEnabled()) {
        log.info("String_Node_Str" + plr.getName() + "String_Node_Str");
      }
      updatePlayerData(npc,plr.getUniqueId());
      despawnNPC(plr.getUniqueId());
    }
  }
  log.info("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Change NullSocket to: class NullSocket extends Socket { private final byte[] buffer = new byte[50];
 * @Override public InputStream getInputStream() { return new ByteArrayInputStream(this.buffer); }
 * @Override public OutputStream getOutputStream() { return new ByteArrayOutputStream(10); } }
 */
@Override public void onDisable(){
  for (  NPC npc : npcm.getNPCs()) {
    UUID uuid=npcm.getNPCIdFromEntity(npc.getBukkitEntity());
    updatePlayerData(npc,uuid);
    npcm.despawnById(uuid);
    if (isDebugEnabled()) {
      log.info("String_Node_Str" + uuid);
    }
  }
  log.info("String_Node_Str");
}
Program: 43909
Project: 43909
Buggy source:
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) public void onPlayerJoin(PlayerJoinEvent event){
  Player loginPlayer=event.getPlayer();
  if (plugin.hasDataContainer(loginPlayer.getName())) {
    PlayerDataContainer loginDataContainer=plugin.getPlayerData(loginPlayer.getName());
    if (loginDataContainer.hasSpawnedNPC()) {
      CraftPlayer cPlayer=(CraftPlayer)loginPlayer;
      EntityPlayer ePlayer=cPlayer.getHandle();
      ePlayer.invulnerableTicks=0;
      plugin.despawnNPC(loginDataContainer);
    }
    if (loginDataContainer.shouldBePunished()) {
      loginPlayer.setExp(loginDataContainer.getExp());
      loginPlayer.getInventory().setArmorContents(loginDataContainer.getPlayerArmor());
      loginPlayer.getInventory().setContents(loginDataContainer.getPlayerInventory());
      int healthSet=plugin.healthCheck(loginDataContainer.getHealth());
      loginPlayer.setHealth(healthSet);
      assert(loginPlayer.getHealth() == loginDataContainer.getHealth());
      loginPlayer.setLastDamageCause(new EntityDamageEvent(loginPlayer,DamageCause.ENTITY_EXPLOSION,0));
      loginPlayer.setNoDamageTicks(0);
    }
    if (loginPlayer.getHealth() > 0) {
      loginDataContainer.setPvPTimeout(plugin.getTagDuration());
    }
    loginDataContainer.setShouldBePunished(false);
    loginDataContainer.setSpawnedNPC(false);
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) public void onPlayerJoin(PlayerJoinEvent event){
  Player loginPlayer=event.getPlayer();
  if (plugin.hasDataContainer(loginPlayer.getName())) {
    PlayerDataContainer loginDataContainer=plugin.getPlayerData(loginPlayer.getName());
    if (loginDataContainer.hasSpawnedNPC()) {
      CraftPlayer cPlayer=(CraftPlayer)loginPlayer;
      EntityPlayer ePlayer=cPlayer.getHandle();
      ePlayer.invulnerableTicks=0;
      plugin.despawnNPC(loginDataContainer);
      if (loginPlayer.getHealth() > 0) {
        loginDataContainer.setPvPTimeout(plugin.getTagDuration());
      }
    }
    if (loginDataContainer.shouldBePunished()) {
      loginPlayer.setExp(loginDataContainer.getExp());
      loginPlayer.getInventory().setArmorContents(loginDataContainer.getPlayerArmor());
      loginPlayer.getInventory().setContents(loginDataContainer.getPlayerInventory());
      int healthSet=plugin.healthCheck(loginDataContainer.getHealth());
      loginPlayer.setHealth(healthSet);
      assert(loginPlayer.getHealth() == loginDataContainer.getHealth());
      loginPlayer.setLastDamageCause(new EntityDamageEvent(loginPlayer,DamageCause.ENTITY_EXPLOSION,0));
      loginPlayer.setNoDamageTicks(0);
    }
    loginDataContainer.setShouldBePunished(false);
    loginDataContainer.setSpawnedNPC(false);
  }
}
Program: 43910
Project: 43910
Buggy source:
@SuppressWarnings("String_Node_Str") @EventHandler public void onChunkLoad(ChunkLoadEvent event){
  for (  NPC npc : npcs.values()) {
    if (npc != null && event.getChunk() == npc.getBukkitEntity().getLocation().getBlock().getChunk()) {
      BWorld world=getBWorld(event.getWorld());
      world.getWorldServer().addEntity(npc.getEntity());
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @EventHandler public void onChunkLoad(ChunkLoadEvent event){
  for (  NPC npc : npcs.values()) {
    if (npc != null && event.getChunk() == npc.getBukkitEntity().getLocation().getBlock().getChunk()) {
      BWorld world=getBWorld(event.getWorld());
      if (world.getWorldServer().getEntity(npc.getEntity().id) != npc.getEntity()) {
        world.getWorldServer().addEntity(npc.getEntity());
      }
    }
  }
}
Program: 43911
Project: 43911
Buggy source:
public void rename(String id,String name){
  if (name.length() > 16) {
    String tmp=name.substring(0,16);
    server.getLogger().log(Level.WARNING,"String_Node_Str");
    server.getLogger().log(Level.WARNING,name + "String_Node_Str" + tmp);
    name=tmp;
  }
  HumanNPC npc=(HumanNPC)getNPC(id);
  npc.setName(name);
  BWorld b=getBWorld(npc.getBukkitEntity().getLocation().getWorld());
  WorldServer s=(WorldServer)b.getWorldServer();
  try {
    Method m=s.getClass().getDeclaredMethod("String_Node_Str",new Class[]{Entity.class});
    m.setAccessible(true);
    m.invoke(s,npc.getEntity());
    m=s.getClass().getDeclaredMethod("String_Node_Str",new Class[]{Entity.class});
    m.setAccessible(true);
    m.invoke(s,npc.getEntity());
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  s.everyoneSleeping();
}

Fixed version (ground truth):
public void rename(String id,String name){
  if (name.length() > 16) {
    String tmp=name.substring(0,16);
    server.getLogger().log(Level.WARNING,"String_Node_Str");
    server.getLogger().log(Level.WARNING,name + "String_Node_Str" + tmp);
    name=tmp;
  }
  HumanNPC npc=(HumanNPC)getNPC(id);
  npc.setName(name);
  BWorld b=getBWorld(npc.getBukkitEntity().getLocation().getWorld());
  WorldServer s=b.getWorldServer();
  try {
    Method m=s.getClass().getDeclaredMethod("String_Node_Str",new Class[]{Entity.class});
    m.setAccessible(true);
    m.invoke(s,npc.getEntity());
    m=s.getClass().getDeclaredMethod("String_Node_Str",new Class[]{Entity.class});
    m.setAccessible(true);
    m.invoke(s,npc.getEntity());
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  s.everyoneSleeping();
}
Program: 43912
Project: 43912
Buggy source:
public void lookAtPoint(Location point){
  if (getEntity().getBukkitEntity().getWorld() != point.getWorld()) {
    return;
  }
  Location npcLoc=((LivingEntity)getEntity().getBukkitEntity()).getEyeLocation();
  double xDiff=point.getX() - npcLoc.getX();
  double yDiff=point.getY() - npcLoc.getY();
  double zDiff=point.getZ() - npcLoc.getZ();
  double DistanceXZ=Math.sqrt(xDiff * xDiff + zDiff * zDiff);
  double DistanceY=Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
  double newYaw=Math.acos(xDiff / DistanceXZ) * 180 / Math.PI;
  double newPitch=Math.acos(yDiff / DistanceY) * 180 / Math.PI - 90;
  if (zDiff < 0.0) {
    newYaw=newYaw + Math.abs(180 - newYaw) * 2;
  }
  getEntity().yaw=(float)(newYaw - 90);
  getEntity().pitch=(float)newPitch;
  ((EntityPlayer)getEntity()).bU=(float)(newYaw - 90);
}

Fixed version (ground truth):
public void lookAtPoint(Location point){
  if (getEntity().getBukkitEntity().getWorld() != point.getWorld()) {
    return;
  }
  Location npcLoc=((LivingEntity)getEntity().getBukkitEntity()).getEyeLocation();
  double xDiff=point.getX() - npcLoc.getX();
  double yDiff=point.getY() - npcLoc.getY();
  double zDiff=point.getZ() - npcLoc.getZ();
  double DistanceXZ=Math.sqrt(xDiff * xDiff + zDiff * zDiff);
  double DistanceY=Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
  double newYaw=Math.acos(xDiff / DistanceXZ) * 180 / Math.PI;
  double newPitch=Math.acos(yDiff / DistanceY) * 180 / Math.PI - 90;
  if (zDiff < 0.0) {
    newYaw=newYaw + Math.abs(180 - newYaw) * 2;
  }
  getEntity().yaw=(float)(newYaw - 90);
  getEntity().pitch=(float)newPitch;
  ((EntityPlayer)getEntity()).az=(float)(newYaw - 90);
}
Program: 43913
Project: 43913
Buggy source:
public boolean WarArenaHook(Player plr){
  boolean notInArena=true;
  if (plugin.getServer().getPluginManager().getPlugin("String_Node_Str") != null) {
    notInArena=Warzone.getZoneByPlayerName(plr.getName()) == null && Warzone.getZoneByPlayerName(plr.getName()) == null;
  }
  return notInArena;
}

Fixed version (ground truth):
public boolean WarArenaHook(Player plr){
  boolean notInArena=true;
  if (plugin.getServer().getPluginManager().getPlugin("String_Node_Str") != null) {
    notInArena=Warzone.getZoneByPlayerName(plr.getName()) == null;
  }
  return notInArena;
}
Program: 43914
Project: 43914
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public void onTeleport(PlayerTeleportEvent event){
  if (plugin.hasDataContainer(event.getPlayer().getName())) {
    PlayerDataContainer playerData=plugin.getPlayerData(event.getPlayer().getName());
    if (plugin.settings.blockTeleport() == true && !playerData.hasPVPtagExpired()) {
      TeleportCause cause=event.getCause();
      if (cause == TeleportCause.PLUGIN || cause == TeleportCause.COMMAND) {
        event.getPlayer().sendMessage(ChatColor.RED + "String_Node_Str");
        event.setCancelled(true);
      }
    }
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public void onTeleport(PlayerTeleportEvent event){
  if (event.isCancelled()) {
    return;
  }
  if (plugin.hasDataContainer(event.getPlayer().getName())) {
    PlayerDataContainer playerData=plugin.getPlayerData(event.getPlayer().getName());
    if (plugin.settings.blockTeleport() == true && !playerData.hasPVPtagExpired()) {
      TeleportCause cause=event.getCause();
      if ((cause == TeleportCause.PLUGIN || cause == TeleportCause.COMMAND) && (event.getFrom().distance(event.getTo()) > 8)) {
        event.getPlayer().sendMessage(ChatColor.RED + "String_Node_Str");
        event.setCancelled(true);
      }
    }
  }
}
Program: 43916
Project: 43916
Buggy source:
private void onPlayerJoinNPCMode(Player loginPlayer){
  if (plugin.hasDataContainer(loginPlayer.getName())) {
    PlayerDataContainer loginDataContainer=plugin.getPlayerData(loginPlayer.getName());
    if (loginDataContainer.hasSpawnedNPC()) {
      if (plugin.isDebugEnabled()) {
        plugin.log.info("String_Node_Str");
      }
      plugin.despawnNPC(loginDataContainer);
    }
    if (plugin.isDebugEnabled()) {
      plugin.log.info("String_Node_Str" + loginDataContainer.getPlayerName() + "String_Node_Str");
    }
    if (loginDataContainer.shouldBePunished()) {
      if (plugin.isDebugEnabled()) {
        plugin.log.info("String_Node_Str");
      }
      loginPlayer.setExp(loginDataContainer.getExp());
      loginPlayer.getInventory().setArmorContents(loginDataContainer.getPlayerArmor());
      loginPlayer.getInventory().setContents(loginDataContainer.getPlayerInventory());
      int healthSet=healthCheck(loginDataContainer);
      loginPlayer.setHealth(healthSet);
      assert(loginPlayer.getHealth() == loginDataContainer.getHealth());
      loginPlayer.setLastDamageCause(new EntityDamageEvent(loginPlayer,DamageCause.ENTITY_EXPLOSION,0));
    }
    plugin.removeDataContainer(loginPlayer.getName());
    plugin.createPlayerData(loginPlayer.getName()).setPvPTimeout(plugin.getTagDuration());
  }
}

Fixed version (ground truth):
private void onPlayerJoinNPCMode(Player loginPlayer){
  if (plugin.hasDataContainer(loginPlayer.getName())) {
    PlayerDataContainer loginDataContainer=plugin.getPlayerData(loginPlayer.getName());
    if (loginDataContainer.hasSpawnedNPC()) {
      if (plugin.isDebugEnabled()) {
        plugin.log.info("String_Node_Str");
      }
      plugin.despawnNPC(loginDataContainer);
    }
    if (plugin.isDebugEnabled()) {
      plugin.log.info("String_Node_Str" + loginDataContainer.getPlayerName() + "String_Node_Str");
    }
    if (loginDataContainer.shouldBePunished()) {
      if (plugin.isDebugEnabled()) {
        plugin.log.info("String_Node_Str");
      }
      loginPlayer.setExp(loginDataContainer.getExp());
      loginPlayer.getInventory().setArmorContents(loginDataContainer.getPlayerArmor());
      loginPlayer.getInventory().setContents(loginDataContainer.getPlayerInventory());
      int healthSet=healthCheck(loginDataContainer.getHealth());
      loginPlayer.setHealth(healthSet);
      assert(loginPlayer.getHealth() == loginDataContainer.getHealth());
      loginPlayer.setLastDamageCause(new EntityDamageEvent(loginPlayer,DamageCause.ENTITY_EXPLOSION,0));
    }
    plugin.removeDataContainer(loginPlayer.getName());
    plugin.createPlayerData(loginPlayer.getName()).setPvPTimeout(plugin.getTagDuration());
  }
}
Program: 43917
Project: 43917
Buggy source:
/** 
 * private void onPlayerJoinTimedMode(Player loginPlayer){ if(plugin.hasDataContainer(loginPlayer.getName())){ //Player has a data container and is likely to need some sort of punishment PlayerDataContainer loginDataContainer = plugin.getPlayerData(loginPlayer.getName()); if(loginDataContainer.hasSpawnedNPC()){ //Player has pvplogged and has not been killed yet //despawn the npc and transfer any effects over to the player if(plugin.isDebugEnabled()){plugin.log.info("[CombatTag] Player logged in and has npc");} plugin.despawnNPC(loginDataContainer); } if(plugin.isDebugEnabled()){plugin.log.info("[CombatTag] " + loginDataContainer.getPlayerName() +" should be punushed");} if(loginDataContainer.shouldBePunished()){ if(plugin.isDebugEnabled()){plugin.log.info("[CombatTag] Getting info from NPC and putting it back into the player");} loginPlayer.setExp(loginDataContainer.getExp()); loginPlayer.getInventory().setArmorContents(loginDataContainer.getPlayerArmor()); loginPlayer.getInventory().setContents(loginDataContainer.getPlayerInventory()); int healthSet = healthCheck(loginDataContainer); loginPlayer.setHealth(healthSet); assert(loginPlayer.getHealth() == loginDataContainer.getHealth()); loginPlayer.setLastDamageCause(new EntityDamageEvent(loginPlayer, DamageCause.ENTITY_EXPLOSION, 0)); } plugin.removeDataContainer(loginPlayer.getName()); plugin.createPlayerData(loginPlayer.getName()).setPvPTimeout(plugin.getTagDuration()); } }
 */
private int healthCheck(PlayerDataContainer loginDataContainer){
  int healthSet=loginDataContainer.getHealth();
  if (loginDataContainer.getHealth() < 0) {
    healthSet=0;
  }
  if (loginDataContainer.getHealth() > 20) {
    healthSet=20;
  }
  return healthSet;
}

Fixed version (ground truth):
private int healthCheck(int health){
  if (health < 0) {
    health=0;
  }
  if (health > 20) {
    health=20;
  }
  return health;
}
Program: 43918
Project: 43918
Buggy source:
public void scheduleDelayedKill(String name){
}

Fixed version (ground truth):
public void scheduleDelayedKill(final Player quitPlr,final NPC npc){
  long despawnTicks=settings.getNpcDespawnTime() * 20L;
  final String plrName=quitPlr.getName();
  final Player plrNpc=(Player)npc.getBukkitEntity();
  Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this,new Runnable(){
    @Override public void run(){
      plrNpc.setHealth(0);
      entityListener.onNPCDeath(plrName);
    }
  }
,despawnTicks);
}