nus-yam/ex-repair huggingface dataset:
Program: 161616
Project: 161616
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (!intent.getAction().equals(DownloadService.BROADCAST_NAME)) {
    return;
  }
  String action=intent.getStringExtra(Const.ACTION_EXTRA);
  if (action.length() != 0) {
    Log.i(ActivityForDownloadingExternal.this.getClass().getSimpleName(),"String_Node_Str" + action + "String_Node_Str");
    if (action.equals(Const.COMPLETED)) {
      showLoadingEnded();
      onStart();
    }
    if (action.equals(Const.WARNING)) {
      String message=intent.getStringExtra(Const.WARNING_MESSAGE);
      Utils.showToast(ActivityForDownloadingExternal.this,message);
      showLoadingEnded();
    }
    if (action.equals(Const.ERROR)) {
      String message=intent.getStringExtra(Const.ERROR_MESSAGE);
      showError(message);
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (!intent.getAction().equals(DownloadService.BROADCAST_NAME)) {
    return;
  }
  String action=intent.getStringExtra(Const.ACTION_EXTRA);
  if (action.length() != 0) {
    Utils.logv("String_Node_Str" + action + "String_Node_Str");
    if (action.equals(Const.COMPLETED)) {
      showLoadingEnded();
      onStart();
    }
    if (action.equals(Const.WARNING)) {
      String message=intent.getStringExtra(Const.WARNING_MESSAGE);
      Utils.showToast(ActivityForDownloadingExternal.this,message);
      showLoadingEnded();
    }
    if (action.equals(Const.ERROR)) {
      String message=intent.getStringExtra(Const.ERROR_MESSAGE);
      showError(message);
    }
  }
}
Program: 161617
Project: 161617
Buggy source:
/** 
 * this function allows us to import all lecture items from TUMOnline
 */
void importLecturesFromTUMOnline(){
  TUMOnlineRequest<LecturesSearchRowSet> requestHandler=new TUMOnlineRequest<LecturesSearchRowSet>(TUMOnlineConst.LECTURES_PERSONAL,mContext);
  if (!shouldRefresh(requestHandler.getRequestURL()))   return;
  LecturesSearchRowSet lecturesList=requestHandler.fetch();
  List<LecturesSearchRow> lectures=lecturesList.getLehrveranstaltungen();
  ChatRoomManager manager=new ChatRoomManager(mContext);
  manager.replaceInto(lectures);
}

Fixed version (ground truth):
/** 
 * this function allows us to import all lecture items from TUMOnline
 */
void importLecturesFromTUMOnline(){
  TUMOnlineRequest<LecturesSearchRowSet> requestHandler=new TUMOnlineRequest<LecturesSearchRowSet>(TUMOnlineConst.LECTURES_PERSONAL,mContext);
  if (!shouldRefresh(requestHandler.getRequestURL()))   return;
  LecturesSearchRowSet lecturesList=requestHandler.fetch();
  if (lecturesList == null)   return;
  List<LecturesSearchRow> lectures=lecturesList.getLehrveranstaltungen();
  if (lectures == null)   return;
  ChatRoomManager manager=new ChatRoomManager(mContext);
  manager.replaceInto(lectures);
}
Program: 161619
Project: 161619
Buggy source:
@Override public void onFetch(final String rawResponse){
  new AsyncTask<Void,Void,Boolean>(){
    @Override protected void onPreExecute(){
      showLoadingStart();
      isFetched=true;
    }
    @Override protected Boolean doInBackground(    Void... params){
      calendarManager.importKalendar(rawResponse);
      return true;
    }
    @Override protected void onPostExecute(    Boolean result){
      showLoadingEnded();
      attachSectionPagerAdapter();
      if (Build.VERSION.SDK_INT >= 14) {
        invalidateOptionsMenu();
      }
    }
  }
.execute();
}

Fixed version (ground truth):
@Override public void onFetch(final String rawResponse){
  new AsyncTask<Void,Void,Boolean>(){
    @Override protected void onPreExecute(){
      showLoadingStart();
      isFetched=true;
    }
    @Override protected Boolean doInBackground(    Void... params){
      calendarManager.importCalendar(rawResponse);
      return true;
    }
    @Override protected void onPostExecute(    Boolean result){
      showLoadingEnded();
      attachSectionPagerAdapter();
      if (Build.VERSION.SDK_INT >= 14) {
        invalidateOptionsMenu();
      }
    }
  }
.execute();
}
Program: 161620
Project: 161620
Buggy source:
@Override protected Boolean doInBackground(Void... params){
  calendarManager.importKalendar(rawResponse);
  return true;
}

Fixed version (ground truth):
@Override protected Boolean doInBackground(Void... params){
  calendarManager.importCalendar(rawResponse);
  return true;
}
Program: 161621
Project: 161621
Buggy source:
@Override public void onFetch(ArrayList<HashMap<String,String>> result){
  list=(ListView)findViewById(R.id.list);
  adapter=new RoomFinderListAdapter(this,result);
  list.setAdapter(adapter);
  list.setOnItemClickListener(this);
  if (result.size() == 0) {
    showError(R.string.no_rooms_found);
  }
 else {
    showLoadingEnded();
  }
}

Fixed version (ground truth):
@Override public void onFetch(ArrayList<HashMap<String,String>> result){
  list=(ListView)findViewById(R.id.list);
  RoomFinderListAdapter adapter=new RoomFinderListAdapter(this,result);
  list.setAdapter(adapter);
  list.setOnItemClickListener(this);
  if (result.size() == 0) {
    showError(R.string.no_rooms_found);
  }
 else {
    showLoadingEnded();
  }
}
Program: 161622
Project: 161622
Buggy source:
/** 
 * Starts fetching data from TumOnline in background  {@link #onFetch(String)} gets called if data was fetched successfully.If an error occurred it is handled by  {@link ActivityForAccessingTumOnline}.
 * @param force Force reload of content
 */
void requestFetch(boolean force){
  String accessToken=PreferenceManager.getDefaultSharedPreferences(this).getString(Const.ACCESS_TOKEN,null);
  if (accessToken != null) {
    Log.i(getClass().getSimpleName(),"String_Node_Str" + accessToken + "String_Node_Str");
    showLoadingStart();
    requestHandler.setForce(force);
    requestHandler.fetchInteractive(this,this);
  }
 else {
    Log.i(getClass().getSimpleName(),"String_Node_Str");
    noTokenLayout.setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
/** 
 * Starts fetching data from TumOnline in background  {@link #onFetch(String)} gets called if data was fetched successfully.If an error occurred it is handled by  {@link ActivityForAccessingTumOnline}.
 * @param force Force reload of content
 */
protected void requestFetch(boolean force){
  String accessToken=PreferenceManager.getDefaultSharedPreferences(this).getString(Const.ACCESS_TOKEN,null);
  if (accessToken != null) {
    Log.i(getClass().getSimpleName(),"String_Node_Str" + accessToken + "String_Node_Str");
    showLoadingStart();
    requestHandler.setForce(force);
    requestHandler.fetchInteractive(this,this);
  }
 else {
    Log.i(getClass().getSimpleName(),"String_Node_Str");
    noTokenLayout.setVisibility(View.VISIBLE);
  }
}
Program: 161623
Project: 161623
Buggy source:
/** 
 * Download a JSON stream from a URL
 * @param url Valid URL
 * @return JSONObject
 * @throws Exception
 */
public static JSONObject downloadJson(String url) throws Exception {
  logv("String_Node_Str" + url);
  HttpClient httpclient=new DefaultHttpClient();
  HttpParams params=httpclient.getParams();
  HttpConnectionParams.setSoTimeout(params,Const.HTTP_TIMEOUT);
  HttpConnectionParams.setConnectionTimeout(params,Const.HTTP_TIMEOUT);
  HttpEntity entity;
  try {
    entity=httpclient.execute(new HttpGet(url)).getEntity();
  }
 catch (  Exception e) {
    throw new TimeoutException("String_Node_Str");
  }
  String data="String_Node_Str";
  if (entity != null) {
    InputStream inStream=entity.getContent();
    data=convertStreamToString(inStream);
    logv("String_Node_Str" + data);
    inStream.close();
  }
  return new JSONObject(data);
}

Fixed version (ground truth):
/** 
 * Download a JSON stream from a URL
 * @param url Valid URL
 * @return JSONObject
 * @throws Exception
 */
public static JSONObject downloadJson(String url) throws Exception {
  logv("String_Node_Str" + url);
  HttpClient httpClient=new DefaultHttpClient();
  HttpParams params=httpClient.getParams();
  HttpConnectionParams.setSoTimeout(params,Const.HTTP_TIMEOUT);
  HttpConnectionParams.setConnectionTimeout(params,Const.HTTP_TIMEOUT);
  HttpEntity entity=httpClient.execute(new HttpGet(url)).getEntity();
  String data="String_Node_Str";
  if (entity != null) {
    InputStream inStream=entity.getContent();
    data=convertStreamToString(inStream);
    logv("String_Node_Str" + data);
    inStream.close();
  }
  return new JSONObject(data);
}
Program: 161624
Project: 161624
Buggy source:
@Override public void run(){
  try {
    log(url);
    downloadFile(url,target);
    openDownloads--;
  }
 catch (  Exception e) {
    log(e,url);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    log(url);
    downloadFile(url,target);
  }
 catch (  Exception e) {
    log(e,url);
  }
}
Program: 161625
Project: 161625
Buggy source:
/** 
 * Download a file in a new thread
 * @param url Download location
 * @param target Target filename in local file system
 */
public static void downloadFileThread(final String url,final String target){
  openDownloads++;
  new Thread(new Runnable(){
    @Override public void run(){
      try {
        log(url);
        downloadFile(url,target);
        openDownloads--;
      }
 catch (      Exception e) {
        log(e,url);
      }
    }
  }
).start();
}

Fixed version (ground truth):
/** 
 * Download a file in a new thread
 * @param url Download location
 * @param target Target filename in local file system
 */
public static void downloadFileThread(final String url,final String target){
  new Thread(new Runnable(){
    @Override public void run(){
      try {
        log(url);
        downloadFile(url,target);
      }
 catch (      Exception e) {
        log(e,url);
      }
    }
  }
).start();
}
Program: 161626
Project: 161626
Buggy source:
/** 
 * Downloads an image synchronously from the given url
 * @param url Image url
 * @return Downloaded image as {@link Bitmap}
 */
public static Bitmap downloadImage(final String url){
  openDownloads++;
  Bitmap sourceImage=null;
  try {
    log(url);
    InputStream is=downloadFileStream(url);
    try {
      sourceImage=BitmapFactory.decodeStream(is);
    }
 catch (    Exception e) {
      Utils.log(e);
    }
 finally {
      is.close();
      openDownloads--;
    }
  }
 catch (  Exception e) {
    log(e,url);
  }
  return sourceImage;
}

Fixed version (ground truth):
/** 
 * Downloads an image synchronously from the given url
 * @param url Image url
 * @return Downloaded image as {@link Bitmap}
 */
public static Bitmap downloadImage(final String url){
  Bitmap sourceImage=null;
  try {
    log(url);
    InputStream is=downloadFileStream(url);
    try {
      sourceImage=BitmapFactory.decodeStream(is);
    }
 catch (    Exception e) {
      Utils.log(e);
    }
 finally {
      is.close();
    }
  }
 catch (  Exception e) {
    log(e,url);
  }
  return sourceImage;
}
Program: 161627
Project: 161627
Buggy source:
/** 
 * Replace or Insert a cafeteria in the database
 * @param c Cafeteria object
 * @throws Exception
 */
void replaceIntoDb(Cafeteria c) throws Exception {
  Utils.log(c.toString());
  if (c.id <= 0) {
    throw new Exception("String_Node_Str");
  }
  if (c.name.length() == 0) {
    throw new Exception("String_Node_Str");
  }
  db.execSQL("String_Node_Str",new String[]{String.valueOf(c.id),c.name,c.address,Double.toString(c.latitude),Double.toString(c.longitude)});
}

Fixed version (ground truth):
/** 
 * Replace or Insert a cafeteria in the database
 * @param c Cafeteria object
 * @throws Exception
 */
void replaceIntoDb(Cafeteria c) throws Exception {
  if (c.id <= 0) {
    throw new Exception("String_Node_Str");
  }
  if (c.name.length() == 0) {
    throw new Exception("String_Node_Str");
  }
  db.execSQL("String_Node_Str",new String[]{String.valueOf(c.id),c.name,c.address,Double.toString(c.latitude),Double.toString(c.longitude)});
}
Program: 161628
Project: 161628
Buggy source:
/** 
 * Download cafeterias from external interface (JSON)
 * @param force True to force download over normal sync period, else false
 * @throws Exception
 */
public void downloadFromExternal(boolean force) throws Exception {
  int oldVersion=Utils.getInternalSettingInt(mContext,Const.CAFETERIA_DB_VERSION,1);
  if (oldVersion < 2) {
    db.execSQL("String_Node_Str");
    db.execSQL("String_Node_Str");
    Utils.setInternalSetting(mContext,Const.CAFETERIA_DB_VERSION,2);
    force=true;
  }
  if (!force && !SyncManager.needSync(db,this,TIME_TO_SYNC)) {
    return;
  }
  String url="String_Node_Str";
  JSONArray jsonArray=Utils.downloadJson(url).getJSONArray(Const.JSON_MENSA_MENSEN);
  removeCache();
  db.beginTransaction();
  try {
    for (int i=0; i < jsonArray.length(); i++) {
      replaceIntoDb(getFromJson(jsonArray.getJSONObject(i)));
    }
    SyncManager.replaceIntoDb(db,this);
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
}

Fixed version (ground truth):
/** 
 * Download cafeterias from external interface (JSON)
 * @param force True to force download over normal sync period, else false
 * @throws Exception
 */
public void downloadFromExternal(boolean force) throws Exception {
  int oldVersion=Utils.getInternalSettingInt(mContext,Const.CAFETERIA_DB_VERSION,1);
  if (oldVersion < 2) {
    db.execSQL("String_Node_Str");
    db.execSQL("String_Node_Str");
    Utils.setInternalSetting(mContext,Const.CAFETERIA_DB_VERSION,2);
    force=true;
  }
  if (!force && !SyncManager.needSync(db,this,TIME_TO_SYNC)) {
    return;
  }
  String url="String_Node_Str";
  JSONArray jsonArray=Utils.downloadJsonArray(mContext,url);
  removeCache();
  db.beginTransaction();
  try {
    for (int i=0; i < jsonArray.length(); i++) {
      replaceIntoDb(getFromJson(jsonArray.getJSONObject(i)));
    }
    SyncManager.replaceIntoDb(db,this);
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
}
Program: 161629
Project: 161629
Buggy source:
/** 
 * Get Cafeteria object by JSON object Example JSON: e.g. {"id":"411","name":"Mensa Leopoldstra\u00dfe","anschrift" :"Leopoldstra\u00dfe 13a, M\u00fcnchen"}
 * @param json See example
 * @return Cafeteria object
 * @throws JSONException
 */
private static Cafeteria getFromJson(JSONObject json) throws JSONException {
  return new Cafeteria(json.getInt(Const.JSON_ID),json.getString(Const.JSON_NAME),json.getString(Const.JSON_ANSCHRIFT),48.267510,11.671278);
}

Fixed version (ground truth):
/** 
 * Get Cafeteria object by JSON object Example JSON: e.g. {"mensa":"4", "id":"411","name":"Mensa Leopoldstra\u00dfe","anschrift" :"Leopoldstra\u00dfe 13a, M\u00fcnchen", "latitude":0.0000, "longitude":0.0000}
 * @param json See example
 * @return Cafeteria object
 * @throws JSONException
 */
private static Cafeteria getFromJson(JSONObject json) throws JSONException {
  return new Cafeteria(json.getInt(Const.JSON_ID),json.getString(Const.JSON_NAME),json.getString(Const.JSON_ADDRESS),json.getDouble(Const.JSON_LATITUDE),json.getDouble(Const.JSON_LONGITUDE));
}
Program: 161630
Project: 161630
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  httpClient=new DefaultHttpClient();
  browser=(WebView)this.findViewById(R.id.activity_curricula_web_view);
  browser.getSettings().setBuiltInZoomControls(true);
  String url=getIntent().getExtras().getString(CurriculaActivity.URL);
  String name=getIntent().getExtras().getString(CurriculaActivity.NAME);
  setTitle(name);
  getCurriculum(name,url);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  browser=(WebView)findViewById(R.id.activity_curricula_web_view);
  browser.getSettings().setBuiltInZoomControls(true);
  String url=getIntent().getExtras().getString(CurriculaActivity.URL);
  String name=getIntent().getExtras().getString(CurriculaActivity.NAME);
  setTitle(name);
  startLoading(url);
}
Program: 161631
Project: 161631
Buggy source:
/** 
 * Extract the results from a document fetched from the given URL.
 * @param url URL pointing to a document where the results are extracted from.
 * @return The results.
 */
private String extractResultsFromURL(String url){
  String text=FileUtils.sendGetRequest(this.httpClient,url);
  if (text == null) {
    return this.getString(R.string.something_wrong);
  }
  return Utils.cutText(text,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Extract the results from a document fetched from the given URL.
 * @param url URL pointing to a document where the results are extracted from.
 * @return The results.
 */
private String extractResultsFromURL(String url){
  String text=Utils.downloadFileAndCache(this,url,CacheManager.VALIDITY_ONE_MONTH);
  if (text == null && !Utils.isConnected(this)) {
    showNoInternetLayout();
  }
 else   if (text == null) {
    showError(R.string.something_wrong);
  }
  return Utils.cutText(text,"String_Node_Str","String_Node_Str");
}
Program: 161632
Project: 161632
Buggy source:
/** 
 * Fetch information in a background task and show progress dialog in meantime
 */
@Override protected File onLoadInBackground(Object... params){
  fetchCurriculum((String)params[0],(File)params[1]);
  return (File)params[1];
}

Fixed version (ground truth):
/** 
 * Fetch information in a background task and show progress dialog in meantime
 */
@Override protected String onLoadInBackground(String... params){
  return fetchCurriculum(params[0]);
}
Program: 161633
Project: 161633
Buggy source:
/** 
 * When file is available, open it
 * @param result File
 */
@Override protected void onLoadFinished(File result){
  openFile(result);
  showLoadingEnded();
}

Fixed version (ground truth):
/** 
 * When html data is loaded show it in webView
 * @param result File
 */
@Override protected void onLoadFinished(String result){
  browser.loadData(result,"String_Node_Str",null);
  showLoadingEnded();
}
Program: 161634
Project: 161634
Buggy source:
/** 
 * Fetches the curriculum document and extracts all relevant information.
 * @param url URL of the curriculum document
 * @param targetFile Target where the results should be written to
 */
private void fetchCurriculum(String url,File targetFile){
  String text=Utils.buildHTMLDocument(FileUtils.sendGetRequest(httpClient,"String_Node_Str"),"String_Node_Str" + extractResultsFromURL(url) + "String_Node_Str");
  text=text.replace("String_Node_Str","String_Node_Str");
  FileUtils.writeFile(targetFile,text);
}

Fixed version (ground truth):
/** 
 * Fetches the curriculum document and extracts all relevant information.
 * @param url URL of the curriculum document
 */
private String fetchCurriculum(String url){
  String text=Utils.buildHTMLDocument(Utils.downloadFileAndCache(this,"String_Node_Str",CacheManager.VALIDITY_ONE_MONTH),"String_Node_Str" + extractResultsFromURL(url) + "String_Node_Str");
  return text.replace("String_Node_Str","String_Node_Str");
}
Program: 161635
Project: 161635
Buggy source:
@SuppressWarnings("String_Node_Str") @Override protected void onStart(){
  super.onStart();
  NewsManager nm=new NewsManager(this);
  Cursor cursor=nm.getAllFromDb();
  startManagingCursor(cursor);
  if (cursor.getCount() > 0) {
    SimpleCursorAdapter adapter=new SimpleCursorAdapter(this,R.layout.card_news_item,cursor,cursor.getColumnNames(),new int[]{R.id.news_img,R.id.news_title,R.id.news_src_date,R.id.news_src_title,R.id.news_src_icon});
    adapter.setViewBinder(this);
    ListView lv=(ListView)findViewById(R.id.activity_news_list_view);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(this);
    lv.setDividerHeight(0);
    NewsManager.lastInserted=0;
  }
 else {
    showErrorLayout();
  }
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  NewsManager nm=new NewsManager(this);
  Cursor cursor=nm.getAllFromDb();
  if (cursor.getCount() > 0) {
    NewsAdapter adapter=new NewsAdapter(this,cursor);
    lv=(ListView)findViewById(R.id.activity_news_list_view);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(this);
    lv.setDividerHeight(0);
    lv.setSelection(nm.getTodayIndex());
    if (state != null)     lv.onRestoreInstanceState(state);
  }
 else {
    showErrorLayout();
  }
}
Program: 161636
Project: 161636
Buggy source:
/** 
 * If news item has been clicked open the corresponding link
 * @param adapterView Containing listView
 * @param view Item view
 * @param position Index of the item
 * @param id Item id
 */
@SuppressWarnings("String_Node_Str") @Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long id){
  ListView lv=(ListView)findViewById(R.id.activity_news_list_view);
  Cursor cursor=(Cursor)lv.getAdapter().getItem(position);
  startManagingCursor(cursor);
  String url=cursor.getString(cursor.getColumnIndex(Const.LINK_COLUMN));
  if (url.length() == 0) {
    Utils.showToast(this,R.string.no_link_existing);
    return;
  }
  Intent viewIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));
  startActivity(viewIntent);
}

Fixed version (ground truth):
/** 
 * If news item has been clicked open the corresponding link
 * @param adapterView Containing listView
 * @param view Item view
 * @param position Index of the item
 * @param id Item id
 */
@Override public void onItemClick(AdapterView<?> adapterView,View view,int position,long id){
  Cursor cursor=(Cursor)lv.getAdapter().getItem(position);
  String url=cursor.getString(cursor.getColumnIndex(Const.LINK_COLUMN));
  if (url.length() == 0) {
    Utils.showToast(this,R.string.no_link_existing);
    return;
  }
  startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(url)));
}
Program: 161637
Project: 161637
Buggy source:
/** 
 * Callback method from   {@link de.tum.in.tumcampus.fragments.OpeningHoursListFragment.Callbacks}indicating that the item with the given ID was selected.
 * @param id id of institution
 * @param name name of institution
 */
@Override public void onItemSelected(int id,String name){
  if (mTwoPane) {
    Bundle arguments=new Bundle();
    arguments.putInt(OpeningHoursDetailFragment.ARG_ITEM_ID,id);
    arguments.putString(OpeningHoursDetailFragment.ARG_ITEM_CONTENT,name);
    OpeningHoursDetailFragment fragment=new OpeningHoursDetailFragment();
    fragment.setArguments(arguments);
    getSupportFragmentManager().beginTransaction().replace(R.id.item_detail_container,fragment).commit();
  }
 else {
    Intent detailIntent=new Intent(this,OpeningHoursDetailActivity.class);
    detailIntent.putExtra(OpeningHoursDetailFragment.ARG_ITEM_ID,id);
    detailIntent.putExtra(OpeningHoursDetailFragment.TWO_PANE,mTwoPane);
    startActivity(detailIntent);
  }
}

Fixed version (ground truth):
/** 
 * Callback method from   {@link de.tum.in.tumcampus.fragments.OpeningHoursListFragment.Callbacks}indicating that the item with the given ID was selected.
 * @param id id of institution
 * @param name name of institution
 */
@Override public void onItemSelected(int id,String name){
  if (mTwoPane) {
    Bundle arguments=new Bundle();
    arguments.putInt(OpeningHoursDetailFragment.ARG_ITEM_ID,id);
    arguments.putString(OpeningHoursDetailFragment.ARG_ITEM_CONTENT,name);
    OpeningHoursDetailFragment fragment=new OpeningHoursDetailFragment();
    fragment.setArguments(arguments);
    getSupportFragmentManager().beginTransaction().replace(R.id.item_detail_container,fragment).commit();
  }
 else {
    Intent detailIntent=new Intent(this,OpeningHoursDetailActivity.class);
    detailIntent.putExtra(OpeningHoursDetailFragment.ARG_ITEM_ID,id);
    detailIntent.putExtra(OpeningHoursDetailFragment.ARG_ITEM_CONTENT,name);
    detailIntent.putExtra(OpeningHoursDetailFragment.TWO_PANE,mTwoPane);
    startActivity(detailIntent);
  }
}
Program: 161638
Project: 161638
Buggy source:
private void handleIntent(Intent intent){
  if (intent != null && intent.getAction().equals(Intent.ACTION_SEARCH)) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    EditText searchView=(EditText)this.findViewById(R.id.search_field);
    searchView.setText(query);
    performSearchAlgorithm();
  }
}

Fixed version (ground truth):
private void handleIntent(Intent intent){
  if (intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SEARCH)) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    EditText searchView=(EditText)this.findViewById(R.id.search_field);
    searchView.setText(query);
    performSearchAlgorithm();
  }
}
Program: 161639
Project: 161639
Buggy source:
private void checkPlayServicesAndRegister(){
  if (checkPlayServices()) {
    gcm=GoogleCloudMessaging.getInstance(this);
    regId=getRegistrationId(getApplicationContext());
    if (regId.isEmpty()) {
      registerInBackground();
    }
 else {
      boolean sentToTCAServer=isRegistrationIdSentToTCAServer(getApplicationContext());
      if (!sentToTCAServer) {
        sendRegistrationIdToBackend();
      }
    }
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkPlayServicesAndRegister(){
  currentPrivateKey=retrieveOrGeneratePrivateKey();
  if (checkPlayServices()) {
    gcm=GoogleCloudMessaging.getInstance(this);
    regId=getRegistrationId(getApplicationContext());
    if (regId.isEmpty()) {
      registerInBackground();
    }
 else {
      boolean sentToTCAServer=isRegistrationIdSentToTCAServer(getApplicationContext());
      if (!sentToTCAServer) {
        sendRegistrationIdToBackend();
      }
    }
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
}
Program: 161640
Project: 161640
Buggy source:
private void populateCurrentChatMember(final SharedPreferences sharedPrefs){
  String lrzId=sharedPrefs.getString(Const.LRZ_ID,"String_Node_Str");
  if (sharedPrefs.contains(Const.CHAT_ROOM_DISPLAY_NAME)) {
    List<ChatMember> members=ChatClient.getInstance().getMember(lrzId);
    currentChatMember=members.get(0);
    checkPlayServicesAndRegister();
    currentPrivateKey=retrieveOrGeneratePrivateKey();
  }
 else {
    currentChatMember=new ChatMember(lrzId);
    LinearLayout layout=new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    final EditText etDisplayName=new EditText(this);
    etDisplayName.setHint(R.string.display_name);
    layout.addView(etDisplayName);
    AlertDialog.Builder builder=new AlertDialog.Builder(ChatRoomsSearchActivity.this);
    builder.setTitle(R.string.chat_display_name_title).setView(layout).setPositiveButton(getResources().getString(android.R.string.ok),new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        currentChatMember.setDisplayName(etDisplayName.getText().toString());
        Editor editor=sharedPrefs.edit();
        editor.putString(Const.CHAT_ROOM_DISPLAY_NAME,currentChatMember.getDisplayName());
        editor.commit();
        currentChatMember=ChatClient.getInstance().createMember(currentChatMember);
        checkPlayServicesAndRegister();
        currentPrivateKey=retrieveOrGeneratePrivateKey();
      }
    }
);
    AlertDialog alertDialog=builder.create();
    alertDialog.show();
  }
}

Fixed version (ground truth):
private void populateCurrentChatMember(final SharedPreferences sharedPrefs){
  String lrzId=sharedPrefs.getString(Const.LRZ_ID,"String_Node_Str");
  if (sharedPrefs.contains(Const.CHAT_ROOM_DISPLAY_NAME)) {
    List<ChatMember> members=ChatClient.getInstance().getMember(lrzId);
    currentChatMember=members.get(0);
    checkPlayServicesAndRegister();
  }
 else {
    currentChatMember=new ChatMember(lrzId);
    LinearLayout layout=new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    final EditText etDisplayName=new EditText(this);
    etDisplayName.setHint(R.string.display_name);
    layout.addView(etDisplayName);
    AlertDialog.Builder builder=new AlertDialog.Builder(ChatRoomsSearchActivity.this);
    builder.setTitle(R.string.chat_display_name_title).setView(layout).setPositiveButton(getResources().getString(android.R.string.ok),new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        currentChatMember.setDisplayName(etDisplayName.getText().toString());
        Editor editor=sharedPrefs.edit();
        editor.putString(Const.CHAT_ROOM_DISPLAY_NAME,currentChatMember.getDisplayName());
        editor.commit();
        currentChatMember=ChatClient.getInstance().createMember(currentChatMember);
        checkPlayServicesAndRegister();
      }
    }
);
    AlertDialog alertDialog=builder.create();
    alertDialog.show();
  }
}
Program: 161642
Project: 161642
Buggy source:
private void loadChatHistory(){
  final List<ChatMessage> messageHistory=new ArrayList<ChatMessage>();
  ChatClient.getInstance().getMessagesCb(currentChatRoom.getGroupId(),new Callback<List<ChatMessage>>(){
    @Override public void success(    List<ChatMessage> arg0,    Response arg1){
      Log.d("String_Node_Str",arg0.toString());
    }
    @Override public void failure(    RetrofitError arg0){
      Log.d("String_Node_Str",arg0.toString());
    }
  }
);
  lvMessageHistory.setAdapter(new ChatHistoryAdapter(this,messageHistory));
}

Fixed version (ground truth):
private void loadChatHistory(){
  ChatClient.getInstance().getMessagesCb(currentChatRoom.getGroupId(),new Callback<List<ChatMessage>>(){
    @Override public void success(    List<ChatMessage> chatHistory,    Response arg1){
      Log.d("String_Node_Str",chatHistory.toString());
      lvMessageHistory.setAdapter(new ChatHistoryAdapter(ChatActivity.this,chatHistory));
    }
    @Override public void failure(    RetrofitError arg0){
      Log.e("String_Node_Str",arg0.toString());
    }
  }
);
}
Program: 161643
Project: 161643
Buggy source:
@Override public void success(List<ChatMessage> arg0,Response arg1){
  Log.d("String_Node_Str",arg0.toString());
}

Fixed version (ground truth):
@Override public void success(List<ChatMessage> chatHistory,Response arg1){
  Log.d("String_Node_Str",chatHistory.toString());
  lvMessageHistory.setAdapter(new ChatHistoryAdapter(ChatActivity.this,chatHistory));
}
Program: 161644
Project: 161644
Buggy source:
@Override public void failure(RetrofitError arg0){
  Log.d("String_Node_Str",arg0.toString());
}

Fixed version (ground truth):
@Override public void failure(RetrofitError arg0){
  Log.e("String_Node_Str",arg0.toString());
}
Program: 161645
Project: 161645
Buggy source:
public Date getTimestamp(){
  return timestamp;
}

Fixed version (ground truth):
public String getTimestamp(){
  return timestamp;
}
Program: 161646
Project: 161646
Buggy source:
public void setTimestamp(Date timestamp){
  this.timestamp=timestamp;
}

Fixed version (ground truth):
public void setTimestamp(String timestamp){
  this.timestamp=timestamp;
}
Program: 161650
Project: 161650
Buggy source:
@Test public void startWithoutExecutorTest(){
  profiler.start(null);
  assertTrue(profiler.isRunning());
}

Fixed version (ground truth):
@Test public void startWithoutExecutorTest(){
  profiler.start(null);
  assertTrue(profiler.isRunning());
  blockForProfilerSample();
}
Program: 161651
Project: 161651
Buggy source:
@Override public SubmitterScheduler makeSubmitterScheduler(int poolSize,boolean prestartIfAvailable){
  PriorityScheduler scheduler=schedulerFactory.makePriorityScheduler(poolSize);
  if (prestartIfAvailable) {
    scheduler.prestartAllThreads();
  }
  return new ThreadRenamingPriorityScheduler(scheduler,"String_Node_Str",false);
}

Fixed version (ground truth):
@Override public SubmitterScheduler makeSubmitterScheduler(int poolSize,boolean prestartIfAvailable){
  PriorityScheduler scheduler=schedulerFactory.makePriorityScheduler(poolSize);
  if (prestartIfAvailable) {
    scheduler.prestartAllThreads();
  }
  return new ThreadRenamingPriorityScheduler(scheduler,THREAD_NAME,false);
}
Program: 161652
Project: 161652
Buggy source:
@Test public void getExecutionDurationPercentilesTest(){
  assertEquals(0,statWrapper.getExecutionDurationPercentiles(50).get(50.),0);
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(50).get(50.),1);
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(statWrapper.getExecutionDurationPercentiles(90).get(90.) >= DELAY_TIME);
}

Fixed version (ground truth):
@Test public void getExecutionDurationPercentilesTest(){
  assertEquals(0,statWrapper.getExecutionDurationPercentiles(50).get(50.),0);
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(50).get(50.),1);
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(statWrapper.getExecutionDurationPercentiles(90).get(90.) >= (DELAY_TIME - ALLOWED_VARIANCE));
}
Program: 161653
Project: 161653
Buggy source:
@Test public void getExecutionDurationSamplesTest(){
  assertTrue(statWrapper.getExecutionDurationSamples().isEmpty());
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationSamples().size());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(2,statWrapper.getExecutionDurationSamples().size());
  assertTrue(statWrapper.getExecutionDurationSamples().get(0) < 2);
  assertTrue(statWrapper.getExecutionDurationSamples().get(1) >= DELAY_TIME);
}

Fixed version (ground truth):
@Test public void getExecutionDurationSamplesTest(){
  assertTrue(statWrapper.getExecutionDurationSamples().isEmpty());
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationSamples().size());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(2,statWrapper.getExecutionDurationSamples().size());
  assertTrue(statWrapper.getExecutionDurationSamples().get(0) < 2);
  assertTrue(statWrapper.getExecutionDurationSamples().get(1) >= (DELAY_TIME - ALLOWED_VARIANCE));
}
Program: 161654
Project: 161654
Buggy source:
@Test public void getWithPriorityExecutionDurationPercentilesTest(){
  NoThreadSchedulerStatisticTracker scheduler=new NoThreadSchedulerStatisticTracker();
  assertEquals(0,scheduler.getExecutionDurationPercentiles(TaskPriority.High,50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME),TaskPriority.High);
  scheduler.tick(null);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.High,75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(TaskPriority.High,90).get(90.) >= DELAY_TIME);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.Low,90).get(90.),1);
}

Fixed version (ground truth):
@Test public void getWithPriorityExecutionDurationPercentilesTest(){
  NoThreadSchedulerStatisticTracker scheduler=new NoThreadSchedulerStatisticTracker();
  assertEquals(0,scheduler.getExecutionDurationPercentiles(TaskPriority.High,50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME),TaskPriority.High);
  scheduler.tick(null);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.High,75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(TaskPriority.High,90).get(90.) >= (DELAY_TIME - ALLOWED_VARIANCE));
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.Low,90).get(90.),1);
}
Program: 161655
Project: 161655
Buggy source:
@Test public void getExecutionDurationPercentilesTest(){
  NoThreadSchedulerStatisticTracker scheduler=new NoThreadSchedulerStatisticTracker();
  assertEquals(0,scheduler.getExecutionDurationPercentiles(50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.tick(null);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(50).get(50.),1);
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME));
  scheduler.tick(null);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(90).get(90.) >= DELAY_TIME);
}

Fixed version (ground truth):
@Test public void getExecutionDurationPercentilesTest(){
  NoThreadSchedulerStatisticTracker scheduler=new NoThreadSchedulerStatisticTracker();
  assertEquals(0,scheduler.getExecutionDurationPercentiles(50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.tick(null);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(50).get(50.),1);
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME));
  scheduler.tick(null);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(75).get(75.),1);
  System.out.println(scheduler.getExecutionDurationPercentiles(90).get(90.));
  assertTrue(scheduler.getExecutionDurationPercentiles(90).get(90.) >= (DELAY_TIME - ALLOWED_VARIANCE));
}
Program: 161656
Project: 161656
Buggy source:
public static void getWithPriorityExecutionDurationPercentilesTest(StatisticPriorityScheduler scheduler){
  assertEquals(0,scheduler.getExecutionDurationPercentiles(TaskPriority.High,50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME),TaskPriority.High);
  blockTillSchedulerIdle(scheduler,10);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.High,75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(TaskPriority.High,90).get(90.) >= DELAY_TIME);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.Low,90).get(90.),1);
}

Fixed version (ground truth):
public static void getWithPriorityExecutionDurationPercentilesTest(StatisticPriorityScheduler scheduler){
  assertEquals(0,scheduler.getExecutionDurationPercentiles(TaskPriority.High,50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.Low);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(),TaskPriority.High);
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME),TaskPriority.High);
  blockTillSchedulerIdle(scheduler,10);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.High,75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(TaskPriority.High,90).get(90.) >= (DELAY_TIME - ALLOWED_VARIANCE));
  assertEquals(1,scheduler.getExecutionDurationPercentiles(TaskPriority.Low,90).get(90.),1);
}
Program: 161657
Project: 161657
Buggy source:
public static void getExecutionDurationPercentilesTest(StatisticPriorityScheduler scheduler){
  assertEquals(0,scheduler.getExecutionDurationPercentiles(50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable());
  blockTillSchedulerIdle(scheduler,1);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(50).get(50.),1);
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME));
  blockTillSchedulerIdle(scheduler,5);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(90).get(90.) >= DELAY_TIME);
}

Fixed version (ground truth):
public static void getExecutionDurationPercentilesTest(StatisticPriorityScheduler scheduler){
  assertEquals(0,scheduler.getExecutionDurationPercentiles(50).get(50.),0);
  scheduler.execute(new ClockUpdateRunnable());
  blockTillSchedulerIdle(scheduler,1);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(50).get(50.),1);
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable());
  scheduler.execute(new ClockUpdateRunnable(DELAY_TIME));
  blockTillSchedulerIdle(scheduler,5);
  assertEquals(1,scheduler.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(scheduler.getExecutionDurationPercentiles(90).get(90.) >= DELAY_TIME - ALLOWED_VARIANCE);
}
Program: 161658
Project: 161658
Buggy source:
@Test public void getExecutionDurationPercentilesTest(){
  assertEquals(0,statWrapper.getExecutionDurationPercentiles(50).get(50.),0);
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(50).get(50.),1);
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(statWrapper.getExecutionDurationPercentiles(90).get(90.) >= DELAY_TIME);
}

Fixed version (ground truth):
@Test public void getExecutionDurationPercentilesTest(){
  assertEquals(0,statWrapper.getExecutionDurationPercentiles(50).get(50.),0);
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(50).get(50.),1);
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(DoNothingRunnable.instance());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(1,statWrapper.getExecutionDurationPercentiles(75).get(75.),1);
  assertTrue(statWrapper.getExecutionDurationPercentiles(90).get(90.) >= DELAY_TIME - ALLOWED_VARIANCE);
}
Program: 161659
Project: 161659
Buggy source:
@Test public void getExecutionDurationSamplesTest(){
  assertTrue(statWrapper.getExecutionDurationSamples().isEmpty());
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationSamples().size());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(2,statWrapper.getExecutionDurationSamples().size());
  assertTrue(statWrapper.getExecutionDurationSamples().get(0) < 2);
  assertTrue(statWrapper.getExecutionDurationSamples().get(1) >= DELAY_TIME);
}

Fixed version (ground truth):
@Test public void getExecutionDurationSamplesTest(){
  assertTrue(statWrapper.getExecutionDurationSamples().isEmpty());
  statWrapper.execute(DoNothingRunnable.instance());
  assertEquals(1,statWrapper.getExecutionDurationSamples().size());
  statWrapper.execute(new TestRunnable(DELAY_TIME));
  assertEquals(2,statWrapper.getExecutionDurationSamples().size());
  assertTrue(statWrapper.getExecutionDurationSamples().get(0) < 2);
  assertTrue(statWrapper.getExecutionDurationSamples().get(1) >= DELAY_TIME - ALLOWED_VARIANCE);
}
Program: 161660
Project: 161660
Buggy source:
@Override public TaskWrapper workerIdle(Worker worker){
  TaskWrapper result=super.workerIdle(worker);
  if (result != null && result.task instanceof Wrapper) {
    long taskDelay=result.getRunTime() - Clock.lastKnownForwardProgressingMillis();
    Wrapper statWrapper=(Wrapper)result.task;
    ConcurrentArrayList<Long> priorityStats;
switch (statWrapper.priority) {
case High:
      priorityStats=statsManager.highPriorityExecutionDelay;
    break;
case Low:
  priorityStats=statsManager.lowPriorityExecutionDelay;
break;
case Starvable:
priorityStats=statsManager.starvablePriorityExecutionDelay;
break;
default :
throw new UnsupportedOperationException();
}
synchronized (priorityStats.getModificationLock()) {
priorityStats.add(taskDelay);
StatsManager.trimWindow(priorityStats);
}
}
return result;
}

Fixed version (ground truth):
@Override public TaskWrapper workerIdle(Worker worker){
  TaskWrapper result=super.workerIdle(worker);
  if (result != null && result.task instanceof Wrapper) {
    long taskDelay=result.getPureRunTime() - Clock.lastKnownForwardProgressingMillis();
    Wrapper statWrapper=(Wrapper)result.task;
    ConcurrentArrayList<Long> priorityStats;
switch (statWrapper.priority) {
case High:
      priorityStats=statsManager.highPriorityExecutionDelay;
    break;
case Low:
  priorityStats=statsManager.lowPriorityExecutionDelay;
break;
case Starvable:
priorityStats=statsManager.starvablePriorityExecutionDelay;
break;
default :
throw new UnsupportedOperationException();
}
synchronized (priorityStats.getModificationLock()) {
priorityStats.add(taskDelay);
StatsManager.trimWindow(priorityStats);
}
}
return result;
}
Program: 161661
Project: 161661
Buggy source:
@Override protected void doExecute(Runnable task){
  if (queuedTaskCount.get() >= queuedTaskLimit) {
    throw new RejectedExecutionException();
  }
 else   if (queuedTaskCount.incrementAndGet() > queuedTaskLimit) {
    queuedTaskCount.decrementAndGet();
    throw new RejectedExecutionException();
  }
 else {
    parentExecutor.execute(new DecrementingRunnable(task,queuedTaskCount));
  }
}

Fixed version (ground truth):
@Override protected void doExecute(Runnable task){
  if (queuedTaskCount.get() >= queuedTaskLimit) {
    throw new RejectedExecutionException();
  }
 else   if (queuedTaskCount.incrementAndGet() > queuedTaskLimit) {
    queuedTaskCount.decrementAndGet();
    throw new RejectedExecutionException();
  }
 else {
    try {
      parentExecutor.execute(new DecrementingRunnable(task,queuedTaskCount));
    }
 catch (    RejectedExecutionException e) {
      queuedTaskCount.decrementAndGet();
      throw e;
    }
  }
}
Program: 161662
Project: 161662
Buggy source:
@Override protected void doSchedule(Runnable task,long delayInMillis){
  if (queuedTaskCount.get() >= queuedTaskLimit) {
    throw new RejectedExecutionException();
  }
 else   if (queuedTaskCount.incrementAndGet() > queuedTaskLimit) {
    queuedTaskCount.decrementAndGet();
    throw new RejectedExecutionException();
  }
 else {
    parentScheduler.schedule(new DecrementingRunnable(task,queuedTaskCount),delayInMillis);
  }
}

Fixed version (ground truth):
@Override protected void doSchedule(Runnable task,long delayInMillis){
  if (queuedTaskCount.get() >= queuedTaskLimit) {
    throw new RejectedExecutionException();
  }
 else   if (queuedTaskCount.incrementAndGet() > queuedTaskLimit) {
    queuedTaskCount.decrementAndGet();
    throw new RejectedExecutionException();
  }
 else {
    try {
      parentScheduler.schedule(new DecrementingRunnable(task,queuedTaskCount),delayInMillis);
    }
 catch (    RejectedExecutionException e) {
      queuedTaskCount.decrementAndGet();
      throw e;
    }
  }
}