nus-yam/ex-repair huggingface dataset:
Program: 171701
Project: 171701
Buggy source:
private void loadNowShowingMovies(){
  ApiInterface apiService=ApiClient.getClient().create(ApiInterface.class);
  Call<NowShowingMoviesResponse> call=apiService.getNowShowingMovies(getResources().getString(R.string.MOVIE_DB_API_KEY),1,"String_Node_Str");
  call.enqueue(new Callback<NowShowingMoviesResponse>(){
    @Override public void onResponse(    Call<NowShowingMoviesResponse> call,    Response<NowShowingMoviesResponse> response){
      if (response.code() != 200)       return;
      mNowShowingLayout.setVisibility(View.VISIBLE);
      for (      MovieBrief movieBrief : response.body().getResults()) {
        if (movieBrief.getBackdropPath() != null)         mNowShowingMovies.add(movieBrief);
      }
      mNowShowingAdapter.notifyDataSetChanged();
    }
    @Override public void onFailure(    Call<NowShowingMoviesResponse> call,    Throwable t){
    }
  }
);
}

Fixed version (ground truth):
private void loadNowShowingMovies(){
  final ApiInterface apiService=ApiClient.getClient().create(ApiInterface.class);
  Call<NowShowingMoviesResponse> call=apiService.getNowShowingMovies(getResources().getString(R.string.MOVIE_DB_API_KEY),1,"String_Node_Str");
  call.enqueue(new Callback<NowShowingMoviesResponse>(){
    @Override public void onResponse(    Call<NowShowingMoviesResponse> call,    Response<NowShowingMoviesResponse> response){
      if (response.code() != 200)       return;
      mNowShowingLayout.setVisibility(View.VISIBLE);
      for (      MovieBrief movie : response.body().getResults()) {
        Call<Movie> call2=apiService.getMovieDetails(movie.getId(),getResources().getString(R.string.MOVIE_DB_API_KEY));
        call2.enqueue(new Callback<Movie>(){
          @Override public void onResponse(          Call<Movie> call,          Response<Movie> response){
            if (response.code() != 200)             return;
            if (response.body().getBackdropPath() != null) {
              mNowShowingMovies.add(response.body());
              mNowShowingAdapter.notifyDataSetChanged();
            }
          }
          @Override public void onFailure(          Call<Movie> call,          Throwable t){
          }
        }
);
      }
    }
    @Override public void onFailure(    Call<NowShowingMoviesResponse> call,    Throwable t){
    }
  }
);
}
Program: 171702
Project: 171702
Buggy source:
private void loadMovies(){
  if (pagesOver)   return;
  ApiInterface apiService=ApiClient.getClient().create(ApiInterface.class);
  Call<NowShowingMovieResponse> call=apiService.getNowShowingMovies(getResources().getString(R.string.MOVIE_DB_API_KEY),presentPage,"String_Node_Str");
  Log.d("String_Node_Str",presentPage + "String_Node_Str");
  call.enqueue(new Callback<NowShowingMovieResponse>(){
    @Override public void onResponse(    Call<NowShowingMovieResponse> call,    Response<NowShowingMovieResponse> response){
      if (response.code() != 200)       return;
      mMovies.addAll(response.body().getResults());
      mMoviesAdapter.notifyDataSetChanged();
      if (response.body().getPage() == response.body().getTotalPages())       pagesOver=true;
 else       presentPage++;
    }
    @Override public void onFailure(    Call<NowShowingMovieResponse> call,    Throwable t){
    }
  }
);
}

Fixed version (ground truth):
private void loadMovies(){
  if (pagesOver)   return;
  ApiInterface apiService=ApiClient.getClient().create(ApiInterface.class);
  Call<NowShowingMovieResponse> call=apiService.getNowShowingMovies(getResources().getString(R.string.MOVIE_DB_API_KEY),presentPage,"String_Node_Str");
  call.enqueue(new Callback<NowShowingMovieResponse>(){
    @Override public void onResponse(    Call<NowShowingMovieResponse> call,    Response<NowShowingMovieResponse> response){
      if (response.code() != 200)       return;
      mMovies.addAll(response.body().getResults());
      mMoviesAdapter.notifyDataSetChanged();
      if (response.body().getPage() == response.body().getTotalPages())       pagesOver=true;
 else       presentPage++;
    }
    @Override public void onFailure(    Call<NowShowingMovieResponse> call,    Throwable t){
    }
  }
);
}
Program: 171705
Project: 171705
Buggy source:
@Override public boolean sendKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() >= KeyEvent.KEYCODE_0 && event.getKeyCode() <= KeyEvent.KEYCODE_9) {
    char c=event.getKeyCharacterMap().getNumber(event.getKeyCode());
    commitText(String.valueOf(c),1);
  }
  return super.sendKeyEvent(event);
}

Fixed version (ground truth):
@Override public boolean sendKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
    if (event.getKeyCode() >= KeyEvent.KEYCODE_0 && event.getKeyCode() <= KeyEvent.KEYCODE_9) {
      char c=event.getKeyCharacterMap().getNumber(event.getKeyCode());
      commitText(String.valueOf(c),1);
    }
 else     if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
      deleteSurroundingText(1,0);
    }
  }
  return super.sendKeyEvent(event);
}
Program: 171708
Project: 171708
Buggy source:
private void ConfigureCommon(){
  availableBiomes=ForgeRegistries.BIOMES.getValues();
  StringBuilder biomeNames=new StringBuilder();
  biomeNames.append("String_Node_Str");
  for (  Biome x : this.availableBiomes) {
    biomeNames.append("String_Node_Str" + x.getRegistryName().toString() + "String_Node_Str");
    FMLLog.log.info(x.getRegistryName().toString() + "String_Node_Str" + x.getBiomeName()+ "String_Node_Str"+ x.getTempCategory()+ "String_Node_Str"+ x.getTemperature()+ "String_Node_Str"+ x.isHighHumidity()+ "String_Node_Str"+ x.isMutation()+ "String_Node_Str"+ x.isSnowyBiome()+ "String_Node_Str"+ BiomeDictionary.getTypes(x).toString());
  }
  this.config.setCategoryComment(CATEGORY_FRUIT_TREES_COMMON,biomeNames.toString());
  this.enableFruitTreeGeneration=config.get(CATEGORY_FRUIT_TREES_COMMON,"String_Node_Str",true,"String_Node_Str").getBoolean();
  this.fruitGrowthSpeed=config.get(CATEGORY_FRUIT_TREES_COMMON,"String_Node_Str",25,"String_Node_Str").getInt();
}

Fixed version (ground truth):
private void ConfigureCommon(){
  availableBiomes=ForgeRegistries.BIOMES.getValues();
  StringBuilder biomeNames=new StringBuilder();
  biomeNames.append("String_Node_Str");
  for (  Biome x : this.availableBiomes) {
    biomeNames.append("String_Node_Str" + x.getRegistryName().toString() + "String_Node_Str");
    FMLLog.log.info(x.getRegistryName().toString() + "String_Node_Str" + x.getTempCategory()+ "String_Node_Str"+ x.getTemperature()+ "String_Node_Str"+ x.isHighHumidity()+ "String_Node_Str"+ x.isMutation()+ "String_Node_Str"+ x.isSnowyBiome()+ "String_Node_Str"+ BiomeDictionary.getTypes(x).toString());
  }
  this.config.setCategoryComment(CATEGORY_FRUIT_TREES_COMMON,biomeNames.toString());
  this.enableFruitTreeGeneration=config.get(CATEGORY_FRUIT_TREES_COMMON,"String_Node_Str",true,"String_Node_Str").getBoolean();
  this.fruitGrowthSpeed=config.get(CATEGORY_FRUIT_TREES_COMMON,"String_Node_Str",25,"String_Node_Str").getInt();
}
Program: 171709
Project: 171709
Buggy source:
private @EntryData.EntryType int getEntryType(FragmentManager.BackStackEntry entry){
  return this.entryDataMap.get(entry).type;
}

Fixed version (ground truth):
private int getEntryType(FragmentManager.BackStackEntry entry){
  String result[]=entry.getName().split(ENTRY_TAG_SEPARATOR);
  if (result.length == 2) {
    return Integer.valueOf(result[1]);
  }
  return -1;
}
Program: 171710
Project: 171710
Buggy source:
void showUrlInput(@Nullable String url,String sourceFragment){
  if (isStateSaved()) {
    return;
  }
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final Fragment existingFragment=fragmentManager.findFragmentByTag(UrlInputFragment.FRAGMENT_TAG);
  if (existingFragment != null && existingFragment.isAdded() && !existingFragment.isRemoving()) {
    return;
  }
  this.prepareUrlInput(url,sourceFragment).addToBackStack(this.entryDataMap.add(UrlInputFragment.FRAGMENT_TAG,EntryData.TYPE_FLOATING)).commit();
}

Fixed version (ground truth):
void showUrlInput(@Nullable String url,String sourceFragment){
  if (isStateSaved()) {
    return;
  }
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final Fragment existingFragment=fragmentManager.findFragmentByTag(UrlInputFragment.FRAGMENT_TAG);
  if (existingFragment != null && existingFragment.isAdded() && !existingFragment.isRemoving()) {
    return;
  }
  this.prepareUrlInput(url,sourceFragment).addToBackStack(makeEntryTag(UrlInputFragment.FRAGMENT_TAG,EntryData.TYPE_FLOATING)).commit();
}
Program: 171711
Project: 171711
Buggy source:
boolean popScreensUntil(@Nullable String targetEntryName){
  boolean clearAll=(targetEntryName == null);
  FragmentManager manager=this.activity.getSupportFragmentManager();
  int entryCount=manager.getBackStackEntryCount();
  boolean found=false;
  while (entryCount > 0) {
    FragmentManager.BackStackEntry entry=manager.getBackStackEntryAt(entryCount - 1);
    if (!clearAll && TextUtils.equals(targetEntryName,getEntryTag(entry))) {
      found=true;
      break;
    }
    manager.popBackStack();
    entryCount--;
  }
  manager.executePendingTransactions();
  return found;
}

Fixed version (ground truth):
boolean popScreensUntil(@Nullable String targetEntryName,@EntryData.EntryType int type){
  boolean clearAll=(targetEntryName == null);
  FragmentManager manager=this.activity.getSupportFragmentManager();
  int entryCount=manager.getBackStackEntryCount();
  boolean found=false;
  while (entryCount > 0) {
    FragmentManager.BackStackEntry entry=manager.getBackStackEntryAt(entryCount - 1);
    if (!clearAll && TextUtils.equals(targetEntryName,getEntryTag(entry)) && type == getEntryType(entry)) {
      found=true;
      break;
    }
    manager.popBackStack();
    entryCount--;
  }
  manager.executePendingTransactions();
  return found;
}
Program: 171712
Project: 171712
Buggy source:
void popAllScreens(){
  popScreensUntil(null);
}

Fixed version (ground truth):
void popAllScreens(){
  popScreensUntil(null,EntryData.TYPE_ROOT);
}
Program: 171713
Project: 171713
Buggy source:
private String getEntryTag(FragmentManager.BackStackEntry entry){
  return this.entryDataMap.get(entry).tag;
}

Fixed version (ground truth):
private String getEntryTag(FragmentManager.BackStackEntry entry){
  String result[]=entry.getName().split(ENTRY_TAG_SEPARATOR);
  if (result.length == 2) {
    return result[0];
  }
  return "String_Node_Str";
}
Program: 171714
Project: 171714
Buggy source:
private FragmentTransaction prepareFirstRun(){
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final FirstrunFragment fragment=this.activity.createFirstRunFragment();
  FragmentTransaction transaction=fragmentManager.beginTransaction();
  if (fragmentManager.findFragmentByTag(FirstrunFragment.FRAGMENT_TAG) == null) {
    transaction.replace(R.id.container,fragment,FirstrunFragment.FRAGMENT_TAG).addToBackStack(this.entryDataMap.add(FirstrunFragment.FRAGMENT_TAG,EntryData.TYPE_ROOT));
  }
  return transaction;
}

Fixed version (ground truth):
private FragmentTransaction prepareFirstRun(){
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final FirstrunFragment fragment=this.activity.createFirstRunFragment();
  FragmentTransaction transaction=fragmentManager.beginTransaction();
  if (fragmentManager.findFragmentByTag(FirstrunFragment.FRAGMENT_TAG) == null) {
    transaction.replace(R.id.container,fragment,FirstrunFragment.FRAGMENT_TAG).addToBackStack(makeEntryTag(FirstrunFragment.FRAGMENT_TAG,EntryData.TYPE_ROOT));
  }
  return transaction;
}
Program: 171715
Project: 171715
Buggy source:
@Override public void onBackStackChanged(){
  if (this.helper == null) {
    return;
  }
  FragmentManager manager=this.helper.activity.getSupportFragmentManager();
  this.helper.entryDataMap.refreshData(manager);
  Fragment fragment=manager.findFragmentById(R.id.browser);
  if (fragment instanceof BrowserFragment) {
    setBrowserState(shouldKeepBrowserRunning(this.helper),this.helper);
  }
}

Fixed version (ground truth):
@Override public void onBackStackChanged(){
  if (this.helper == null) {
    return;
  }
  FragmentManager manager=this.helper.activity.getSupportFragmentManager();
  Fragment fragment=manager.findFragmentById(R.id.browser);
  if (fragment instanceof BrowserFragment) {
    setBrowserState(shouldKeepBrowserRunning(this.helper),this.helper);
  }
}
Program: 171716
Project: 171716
Buggy source:
private FragmentTransaction prepareHomeScreen(boolean animated,@EntryData.EntryType int type){
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final HomeFragment fragment=this.activity.createHomeFragment();
  FragmentTransaction transaction=fragmentManager.beginTransaction();
  int enterAnim=animated ? R.anim.tab_transition_fade_in : 0;
  int exitAnim=(type == EntryData.TYPE_ROOT) ? 0 : R.anim.tab_transition_fade_out;
  transaction.setCustomAnimations(enterAnim,0,0,exitAnim);
  transaction.add(R.id.container,fragment,HomeFragment.FRAGMENT_TAG);
  transaction.addToBackStack(this.entryDataMap.add(HomeFragment.FRAGMENT_TAG,type));
  return transaction;
}

Fixed version (ground truth):
private FragmentTransaction prepareHomeScreen(boolean animated,@EntryData.EntryType int type){
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final HomeFragment fragment=this.activity.createHomeFragment();
  FragmentTransaction transaction=fragmentManager.beginTransaction();
  int enterAnim=animated ? R.anim.tab_transition_fade_in : 0;
  int exitAnim=(type == EntryData.TYPE_ROOT) ? 0 : R.anim.tab_transition_fade_out;
  transaction.setCustomAnimations(enterAnim,0,0,exitAnim);
  transaction.add(R.id.container,fragment,HomeFragment.FRAGMENT_TAG);
  transaction.addToBackStack(makeEntryTag(HomeFragment.FRAGMENT_TAG,type));
  return transaction;
}
Program: 171717
Project: 171717
Buggy source:
@Nullable public Fragment getTopFragment(){
  FragmentManager manager=this.activity.getSupportFragmentManager();
  int count=manager.getBackStackEntryCount();
  if (count == 0) {
    return getBrowserFragment();
  }
  String tag=this.transactionHelper.getFragmentTag(count - 1);
  return manager.findFragmentByTag(tag);
}

Fixed version (ground truth):
@Nullable public Fragment getTopFragment(){
  Fragment latest=this.transactionHelper.getLatestCommitFragment();
  return (latest == null) ? getBrowserFragment() : latest;
}
Program: 171718
Project: 171718
Buggy source:
String getFragmentTag(int backStackIndex){
  FragmentManager manager=activity.getSupportFragmentManager();
  return getEntryTag(manager.getBackStackEntryAt(backStackIndex));
}

Fixed version (ground truth):
private String getFragmentTag(int backStackIndex){
  FragmentManager manager=activity.getSupportFragmentManager();
  return getEntryTag(manager.getBackStackEntryAt(backStackIndex));
}
Program: 171719
Project: 171719
Buggy source:
@Override public void onBackStackChanged(){
  FragmentManager manager=activity.getSupportFragmentManager();
  int entryCount=manager.getBackStackEntryCount();
  boolean isBrowserForeground=true;
  for (int i=0; i < entryCount; ++i) {
    FragmentManager.BackStackEntry entry=manager.getBackStackEntryAt(i);
    if (getEntryType(entry) != EntryData.TYPE_FLOATING) {
      isBrowserForeground=false;
      break;
    }
  }
  entryDataMap.refreshData(manager);
  Fragment fragment=manager.findFragmentById(R.id.browser);
  if (fragment instanceof BrowserFragment) {
    if (isBrowserForeground) {
      ((BrowserFragment)fragment).goForeground();
    }
 else {
      ((BrowserFragment)fragment).goBackground();
    }
  }
}

Fixed version (ground truth):
@Override public void onBackStackChanged(){
  FragmentManager manager=activity.getSupportFragmentManager();
  entryDataMap.refreshData(manager);
  Fragment fragment=manager.findFragmentById(R.id.browser);
  if (fragment instanceof BrowserFragment) {
    setBrowserState((BrowserFragment)fragment,shouldKeepBrowserRunning(manager));
  }
}
Program: 171720
Project: 171720
Buggy source:
private FragmentTransaction prepareHomeScreen(boolean animated,@EntryData.EntryType int type){
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final HomeFragment fragment=this.activity.createHomeFragment();
  FragmentTransaction transaction=fragmentManager.beginTransaction();
  if (animated) {
    transaction.setCustomAnimations(R.anim.tab_transition_fade_in,R.anim.tab_transition_fade_out,R.anim.tab_transition_fade_in,R.anim.tab_transition_fade_out);
  }
 else {
    transaction.setCustomAnimations(0,0,R.anim.tab_transition_fade_in,R.anim.tab_transition_fade_out);
  }
  transaction.add(R.id.container,fragment,HomeFragment.FRAGMENT_TAG);
  transaction.addToBackStack(entryDataMap.add(HomeFragment.FRAGMENT_TAG,type));
  return transaction;
}

Fixed version (ground truth):
private FragmentTransaction prepareHomeScreen(boolean animated,@EntryData.EntryType int type){
  final FragmentManager fragmentManager=this.activity.getSupportFragmentManager();
  final HomeFragment fragment=this.activity.createHomeFragment();
  FragmentTransaction transaction=fragmentManager.beginTransaction();
  int enterAnim=animated ? R.anim.tab_transition_fade_in : 0;
  int exitAnim=(type == EntryData.TYPE_ROOT) ? 0 : R.anim.tab_transition_fade_out;
  transaction.setCustomAnimations(enterAnim,0,0,exitAnim);
  transaction.add(R.id.container,fragment,HomeFragment.FRAGMENT_TAG);
  transaction.addToBackStack(entryDataMap.add(HomeFragment.FRAGMENT_TAG,type));
  return transaction;
}
Program: 171721
Project: 171721
Buggy source:
public static void requestPinShortcut(@NonNull final Context context,@NonNull final Intent shortcutIntent,@NonNull final String title,@NonNull final String urlAsShortcutId,final Bitmap bitmap){
  final Bitmap icon;
  final Resources resources=context.getResources();
  final char representativeCharacter=FavIconUtils.getRepresentativeCharacter(urlAsShortcutId);
  if (bitmap == null) {
    icon=FavIconUtils.getInitialBitmap(resources,null,representativeCharacter);
  }
 else {
    icon=FavIconUtils.getRefinedShortcutIcon(resources,bitmap,representativeCharacter);
  }
  String label=title;
  if (TextUtils.isEmpty(title)) {
    label=urlAsShortcutId;
  }
  final ShortcutInfoCompat shortcut=new ShortcutInfoCompat.Builder(context,urlAsShortcutId).setShortLabel(label).setIcon(IconCompat.createWithBitmap(icon)).setIntent(shortcutIntent).build();
  final Intent showHome=new Intent(Intent.ACTION_MAIN);
  showHome.addCategory(Intent.CATEGORY_HOME);
  showHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  final PendingIntent pendingIntent=PendingIntent.getActivity(context,0,showHome,PendingIntent.FLAG_UPDATE_CURRENT);
  final IntentSender intentSender=pendingIntent.getIntentSender();
  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
    final ShortcutManager shortcutManager=context.getSystemService(ShortcutManager.class);
    if (shortcutManager != null) {
      final List<ShortcutInfo> list=new ArrayList<>();
      list.add(shortcut.toShortcutInfo());
      shortcutManager.updateShortcuts(list);
    }
  }
  if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
    ShortcutManagerCompat.requestPinShortcut(context,shortcut,intentSender);
  }
}

Fixed version (ground truth):
public static void requestPinShortcut(@NonNull final Context context,@NonNull final Intent shortcutIntent,@NonNull final String title,@NonNull final String urlAsShortcutId,final Bitmap bitmap){
  final Bitmap icon;
  final Resources resources=context.getResources();
  final char representativeCharacter=FavIconUtils.getRepresentativeCharacter(urlAsShortcutId);
  if (bitmap == null) {
    icon=FavIconUtils.getInitialBitmap(resources,null,representativeCharacter);
  }
 else {
    icon=FavIconUtils.getRefinedShortcutIcon(resources,bitmap,representativeCharacter);
  }
  String label=title;
  if (TextUtils.isEmpty(title)) {
    label=urlAsShortcutId;
  }
  final ShortcutInfoCompat shortcut=new ShortcutInfoCompat.Builder(context,urlAsShortcutId).setShortLabel(label).setIcon(IconCompat.createWithBitmap(icon)).setIntent(shortcutIntent).build();
  final Intent showHome=new Intent(Intent.ACTION_MAIN);
  showHome.addCategory(Intent.CATEGORY_HOME);
  showHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  final PendingIntent pendingIntent=PendingIntent.getActivity(context,0,showHome,PendingIntent.FLAG_UPDATE_CURRENT);
  final IntentSender intentSender=pendingIntent.getIntentSender();
  updateShortcut26(context,shortcut);
  if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
    ShortcutManagerCompat.requestPinShortcut(context,shortcut,intentSender);
  }
}
Program: 171722
Project: 171722
Buggy source:
@After public void tearDown(){
  activityTestRule.getActivity().finishAndRemoveTask();
  if (loadingIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
  }
}

Fixed version (ground truth):
@After public void tearDown(){
  if (loadingIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
  }
}
Program: 171723
Project: 171723
Buggy source:
@After public void tearDown(){
  if (loadingIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
  }
  activityTestRule.getActivity().finishAndRemoveTask();
}

Fixed version (ground truth):
@After public void tearDown(){
  if (loadingIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
  }
}
Program: 171724
Project: 171724
Buggy source:
@After public void tearDown() throws Exception {
  clearDownloadFolder();
  activityRule.getActivity().finishAndRemoveTask();
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  clearDownloadFolder();
}
Program: 171725
Project: 171725
Buggy source:
@After public void tearDown(){
  if (sessionLoadedIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
  }
  activityRule.getActivity().finishAndRemoveTask();
}

Fixed version (ground truth):
@After public void tearDown(){
  if (sessionLoadedIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
  }
}
Program: 171726
Project: 171726
Buggy source:
@After public void tearDown(){
  if (sessionLoadedIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
  }
  if (screenshotIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(screenshotIdlingResource);
  }
  activityTestRule.getActivity().finishAndRemoveTask();
}

Fixed version (ground truth):
@After public void tearDown(){
  if (sessionLoadedIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
  }
  if (screenshotIdlingResource != null) {
    IdlingRegistry.getInstance().unregister(screenshotIdlingResource);
  }
}
Program: 171727
Project: 171727
Buggy source:
private void init(@NonNull Context context,@Nullable AttributeSet attrs){
  mInitialized=true;
  final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.AnimatedProgressBar);
  final int duration=a.getInteger(R.styleable.AnimatedProgressBar_shiftDuration,1000);
  final boolean wrap=a.getBoolean(R.styleable.AnimatedProgressBar_wrapShiftDrawable,false);
  @InterpolatorRes final int itplId=a.getResourceId(R.styleable.AnimatedProgressBar_shiftInterpolator,0);
  a.recycle();
  setProgressDrawable(buildDrawable(getProgressDrawable(),wrap,duration,itplId));
  mPrimaryAnimator=createAnimator(getMax(),mListener);
  mClosingAnimator.setDuration(CLOSING_DURATION);
  mClosingAnimator.setInterpolator(new LinearInterpolator());
  mClosingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(){
    @Override public void onAnimationUpdate(    ValueAnimator valueAnimator){
      mClipRatio=(float)valueAnimator.getAnimatedValue();
      invalidate();
    }
  }
);
  mClosingAnimator.addListener(new Animator.AnimatorListener(){
    @Override public void onAnimationStart(    Animator animator){
      mClipRatio=0f;
    }
    @Override public void onAnimationEnd(    Animator animator){
      setVisibilityImmediately(GONE);
    }
    @Override public void onAnimationCancel(    Animator animator){
      mClipRatio=0f;
    }
    @Override public void onAnimationRepeat(    Animator animator){
    }
  }
);
}

Fixed version (ground truth):
private void init(@NonNull Context context,@Nullable AttributeSet attrs){
  mInitialized=true;
  final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.AnimatedProgressBar);
  final int duration=a.getInteger(R.styleable.AnimatedProgressBar_shiftDuration,1000);
  final boolean wrap=a.getBoolean(R.styleable.AnimatedProgressBar_wrapShiftDrawable,false);
  @InterpolatorRes final int itplId=a.getResourceId(R.styleable.AnimatedProgressBar_shiftInterpolator,INTEPOLATOR_NOT_EXIST);
  a.recycle();
  setProgressDrawable(buildDrawable(getProgressDrawable(),wrap,duration,itplId));
  mPrimaryAnimator=createAnimator(getMax(),mListener);
  mClosingAnimator.setDuration(CLOSING_DURATION);
  mClosingAnimator.setInterpolator(new LinearInterpolator());
  mClosingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(){
    @Override public void onAnimationUpdate(    ValueAnimator valueAnimator){
      mClipRatio=(float)valueAnimator.getAnimatedValue();
      invalidate();
    }
  }
);
  mClosingAnimator.addListener(new Animator.AnimatorListener(){
    @Override public void onAnimationStart(    Animator animator){
      mClipRatio=0f;
    }
    @Override public void onAnimationEnd(    Animator animator){
      setVisibilityImmediately(GONE);
    }
    @Override public void onAnimationCancel(    Animator animator){
      mClipRatio=0f;
    }
    @Override public void onAnimationRepeat(    Animator animator){
    }
  }
);
}
Program: 171728
Project: 171728
Buggy source:
@SuppressWarnings("String_Node_Str") private boolean isValidInterpolator(@InterpolatorRes int itplId){
  return itplId > 0;
}

Fixed version (ground truth):
private boolean isValidInterpolator(@InterpolatorRes int itplId){
  return itplId != INTEPOLATOR_NOT_EXIST;
}
Program: 171729
Project: 171729
Buggy source:
@Override public boolean handles(FaviconModel source,Options options) throws IOException {
  return true;
}

Fixed version (ground truth):
@Override public boolean handles(FaviconModel source,Options options){
  return true;
}
Program: 171730
Project: 171730
Buggy source:
@Nullable @Override public Resource<Bitmap> decode(FaviconModel source,int width,int height,Options options) throws IOException {
  if (source.type == FavIconUtils.TYPE_GENERATED) {
    return null;
  }
  Bitmap refinedBitmap=FavIconUtils.getRefinedBitmap(context.getResources(),source.originalIcon,FavIconUtils.getRepresentativeCharacter(source.url));
  return BitmapResource.obtain(refinedBitmap,glide.getBitmapPool());
}

Fixed version (ground truth):
@Nullable @Override public Resource<Bitmap> decode(FaviconModel source,int width,int height,Options options){
  if (source.type == FavIconUtils.TYPE_GENERATED) {
    return null;
  }
  Bitmap refinedBitmap=FavIconUtils.getRefinedBitmap(context.getResources(),source.originalIcon,FavIconUtils.getRepresentativeCharacter(source.url));
  if (refinedBitmap == source.originalIcon) {
    refinedBitmap=Bitmap.createBitmap(source.originalIcon);
  }
  return BitmapResource.obtain(refinedBitmap,glide.getBitmapPool());
}
Program: 171731
Project: 171731
Buggy source:
@Override public void onReceivedIcon(WebView view,Bitmap icon){
  final String url=view.getUrl();
  if (TextUtils.isEmpty(url)) {
    return;
  }
  final Bitmap refinedBitmap=FavIconUtils.getRefinedBitmap(view.getResources(),icon,FavIconUtils.getRepresentativeCharacter(url));
  final Site site=new Site();
  site.setTitle(view.getTitle());
  site.setUrl(url);
  site.setFavIcon(refinedBitmap);
  BrowsingHistoryManager.getInstance().updateLastEntry(site,null);
  if (this.tabChromeClient != null) {
    this.tabChromeClient.onReceivedIcon(view,refinedBitmap);
  }
}

Fixed version (ground truth):
@Override public void onReceivedIcon(WebView view,Bitmap icon){
  final String url=view.getUrl();
  if (TextUtils.isEmpty(url)) {
    return;
  }
  final Bitmap refinedBitmap=FavIconUtils.getRefinedBitmap(view.getResources(),icon,FavIconUtils.getRepresentativeCharacter(url));
  final Site site=new Site();
  site.setTitle(view.getTitle());
  site.setUrl(url);
  site.setFavIcon(refinedBitmap);
  BrowsingHistoryManager.getInstance().updateLastEntry(site,null);
  if (this.tabChromeClient != null) {
    this.tabChromeClient.onReceivedIcon(view,icon);
  }
}
Program: 171732
Project: 171732
Buggy source:
@Override public void updateData(List<Tab> tabs){
  adapter.setData(tabs);
  if (tabs.isEmpty()) {
    ScreenNavigator.get(getContext()).popToHomeScreen(false);
    postOnNextFrame(dismissRunnable);
  }
}

Fixed version (ground truth):
@Override public void updateData(List<Tab> tabs){
  adapter.setData(tabs);
}
Program: 171733
Project: 171733
Buggy source:
@Override public void viewReady(){
  view.showFocusedTab(model.getCurrentTabPosition());
}

Fixed version (ground truth):
@Override public void viewReady(){
  List<Tab> tabs=model.getTabs();
  if (tabs.isEmpty()) {
    view.closeTabTray();
  }
 else {
    view.showFocusedTab(model.getCurrentTabPosition());
  }
}
Program: 171734
Project: 171734
Buggy source:
@Override public void tabCloseClicked(int tabPosition){
  int oldFocusPos=model.getCurrentTabPosition();
  model.removeTab(tabPosition);
  List<Tab> newTabs=model.getTabs();
  int newFocusTab=model.getCurrentTabPosition();
  view.tabRemoved(tabPosition,oldFocusPos,oldFocusPos,newFocusTab);
  view.updateData(newTabs);
  if (!newTabs.isEmpty()) {
    model.switchTab(newFocusTab);
  }
}

Fixed version (ground truth):
@Override public void tabCloseClicked(int tabPosition){
  int oldFocusPos=model.getCurrentTabPosition();
  model.removeTab(tabPosition);
  List<Tab> newTabs=model.getTabs();
  int newFocusTab=model.getCurrentTabPosition();
  view.tabRemoved(tabPosition,oldFocusPos,oldFocusPos,newFocusTab);
  view.updateData(newTabs);
  if (!newTabs.isEmpty()) {
    model.switchTab(newFocusTab);
  }
 else {
    view.closeTabTray();
    view.navigateToHome();
  }
}
Program: 171735
Project: 171735
Buggy source:
@Override public void tabCloseClicked(int tabPosition){
  List<Tab> oldTabs=model.getTabs();
  int oldFocusPos=model.getCurrentTabPosition();
  Tab oldFocusTab=oldTabs.get(oldFocusPos);
  model.removeTab(tabPosition);
  List<Tab> newTabs=model.getTabs();
  int newFocusTab=model.getCurrentTabPosition();
  view.tabRemoved(tabPosition,oldFocusPos,newTabs.indexOf(oldFocusTab),newFocusTab);
  view.updateData(newTabs);
  if (!newTabs.isEmpty()) {
    model.switchTab(newFocusTab);
  }
}

Fixed version (ground truth):
@Override public void tabCloseClicked(int tabPosition){
  int oldFocusPos=model.getCurrentTabPosition();
  model.removeTab(tabPosition);
  List<Tab> newTabs=model.getTabs();
  int newFocusTab=model.getCurrentTabPosition();
  view.tabRemoved(tabPosition,oldFocusPos,oldFocusPos,newFocusTab);
  view.updateData(newTabs);
  if (!newTabs.isEmpty()) {
    model.switchTab(newFocusTab);
  }
}
Program: 171736
Project: 171736
Buggy source:
@Override public boolean onCreateWindow(boolean isDialog,boolean isUserGesture,Message msg){
  if (msg == null) {
    return false;
  }
  final String id=addTabInternal(null,source.getId(),false,false,null);
  final Tab tab=getTab(id);
  if (tab == null) {
    return false;
  }
  final WebView webView=(WebView)tab.getTabView();
  final WebView.WebViewTransport transport=(WebView.WebViewTransport)msg.obj;
  transport.setWebView(webView);
  msg.sendToTarget();
  notifier.notifyTabFocused(tab,TabsChromeListener.FACTOR_TAB_ADDED);
  return true;
}

Fixed version (ground truth):
@Override public boolean onCreateWindow(boolean isDialog,boolean isUserGesture,Message msg){
  if (msg == null) {
    return false;
  }
  final String id=addTabInternal(null,source.getId(),false,false,null);
  final Tab tab=getTab(id);
  if (tab == null) {
    return false;
  }
  final WebView webView=(WebView)tab.getTabView();
  final WebView.WebViewTransport transport=(WebView.WebViewTransport)msg.obj;
  transport.setWebView(webView);
  msg.sendToTarget();
  return true;
}
Program: 171737
Project: 171737
Buggy source:
public static void showDefaultSettingNotification(Context context){
  final Intent openDefaultBrowserSetting=IntentUtils.genDefaultBrowserSettingIntent(context);
  final PendingIntent openRocketPending=PendingIntent.getBroadcast(context,REQUEST_DEFAULT_CLICK,openDefaultBrowserSetting,PendingIntent.FLAG_ONE_SHOT);
  final String title=context.getString(R.string.app_name);
  final String content=context.getString(R.string.preference_default_browser) + "String_Node_Str";
  NotificationCompat.Builder builder=NotificationUtil.generateNotificationBuilder(context,openRocketPending).setContentTitle(title).setContentText(content);
  NotificationUtil.sendNotification(context,NotificationId.DEFAULT_BROWSER,builder);
  Settings.getInstance(context).setDefaultBrowserSettingDidShow();
}

Fixed version (ground truth):
public static void showDefaultSettingNotification(Context context){
  final Intent openDefaultBrowserSetting=IntentUtils.genDefaultBrowserSettingIntentForBroadcastReceiver(context);
  final PendingIntent openRocketPending=PendingIntent.getBroadcast(context,REQUEST_DEFAULT_CLICK,openDefaultBrowserSetting,PendingIntent.FLAG_ONE_SHOT);
  final String title=context.getString(R.string.app_name);
  final String content=context.getString(R.string.preference_default_browser) + "String_Node_Str";
  NotificationCompat.Builder builder=NotificationUtil.generateNotificationBuilder(context,openRocketPending).setContentTitle(title).setContentText(content);
  NotificationUtil.sendNotification(context,NotificationId.DEFAULT_BROWSER,builder);
  Settings.getInstance(context).setDefaultBrowserSettingDidShow();
}
Program: 171738
Project: 171738
Buggy source:
@Override protected void onClick(){
  final Context context=getContext();
  final Intent intent=IntentUtils.genDefaultBrowserSettingIntent(context);
  context.startActivity(intent);
}

Fixed version (ground truth):
@Override protected void onClick(){
  final Context context=getContext();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    openDefaultAppsSettings(context);
  }
 else {
    openSumoPage(context);
  }
}
Program: 171739
Project: 171739
Buggy source:
private void insertTab(final int parentIdx,@NonNull final Tab tab){
  final Tab parentTab=(parentIdx >= 0 && parentIdx < tabs.size() - 1) ? tabs.get(parentIdx) : null;
  if (parentTab == null) {
    tabs.add(tab);
    return;
  }
 else {
    tabs.add(parentIdx + 1,tab);
  }
  for (  final Tab t : tabs) {
    if (parentTab.getId().equals(t.getParentId())) {
      t.setParentId(tab.getId());
    }
  }
  tab.setParentId(parentTab.getId());
}

Fixed version (ground truth):
private void insertTab(final int parentIdx,@NonNull final Tab tab){
  final Tab parentTab=(parentIdx >= 0 && parentIdx < tabs.size()) ? tabs.get(parentIdx) : null;
  if (parentTab == null) {
    tabs.add(tab);
    return;
  }
 else {
    tabs.add(parentIdx + 1,tab);
  }
  for (  final Tab t : tabs) {
    if (parentTab.getId().equals(t.getParentId())) {
      t.setParentId(tab.getId());
    }
  }
  tab.setParentId(parentTab.getId());
}
Program: 171740
Project: 171740
Buggy source:
@Override public @SiteIdentity.SecurityState int getSecurityState(){
  return SiteIdentity.UNKNOWN;
}

Fixed version (ground truth):
@Override @SiteIdentity.SecurityState public int getSecurityState(){
  return SiteIdentity.UNKNOWN;
}
Program: 171741
Project: 171741
Buggy source:
@Test public void testRestore(){
  session.restoreTabs(models,urls[0]);
  Assert.assertEquals(session.getTabs().size(),urls.length);
  session.addTab(null,"String_Node_Str",false,false);
}

Fixed version (ground truth):
@Test public void testRestore(){
  session.restoreTabs(models,urls[0]);
  Assert.assertEquals(session.getTabs().size(),urls.length);
  Assert.assertEquals(session.getFocusTab().getId(),urls[0]);
}
Program: 171742
Project: 171742
Buggy source:
@Test public void testAddTab3(){
  String tabId0=session.addTab(null,"String_Node_Str",false,false);
  String tabId1=session.addTab(null,"String_Node_Str",false,false);
  String tabId2=session.addTab(tabId0,"String_Node_Str",false,false);
  String tabId3=session.addTab(tabId0,"String_Node_Str",false,false);
  Assert.assertEquals(session.getTabs().get(0).getId(),tabId0);
  Assert.assertEquals(session.getTabs().get(1).getId(),tabId3);
  Assert.assertEquals(session.getTabs().get(2).getId(),tabId2);
  Assert.assertEquals(session.getTabs().get(3).getId(),tabId1);
  Assert.assertTrue(TextUtils.isEmpty(session.getTabs().get(0).getParentId()));
  Assert.assertEquals(session.getTabs().get(1).getParentId(),tabId0);
  Assert.assertEquals(session.getTabs().get(2).getParentId(),tabId3);
  Assert.assertTrue(TextUtils.isEmpty(session.getTabs().get(3).getParentId()));
}

Fixed version (ground truth):
@Test public void testAddTab3(){
  String tabId0=session.addTab(null,"String_Node_Str",false,false);
  String tabId1=session.addTab(null,"String_Node_Str",false,false);
  String tabId2=session.addTab(tabId0,"String_Node_Str",false,false);
  String tabId3=session.addTab(tabId0,"String_Node_Str",false,false);
  String tabId4=session.addTab(tabId1,"String_Node_Str",false,false);
  String tabId5=session.addTab(tabId4,"String_Node_Str",false,false);
  Assert.assertEquals(session.getTabs().get(0).getId(),tabId0);
  Assert.assertEquals(session.getTabs().get(1).getId(),tabId3);
  Assert.assertEquals(session.getTabs().get(2).getId(),tabId2);
  Assert.assertEquals(session.getTabs().get(3).getId(),tabId1);
  Assert.assertEquals(session.getTabs().get(4).getId(),tabId4);
  Assert.assertEquals(session.getTabs().get(5).getId(),tabId5);
  Assert.assertTrue(TextUtils.isEmpty(session.getTabs().get(0).getParentId()));
  Assert.assertEquals(session.getTabs().get(1).getParentId(),tabId0);
  Assert.assertEquals(session.getTabs().get(2).getParentId(),tabId3);
  Assert.assertTrue(TextUtils.isEmpty(session.getTabs().get(3).getParentId()));
  Assert.assertEquals(session.getTabs().get(4).getParentId(),tabId1);
  Assert.assertEquals(session.getTabs().get(5).getParentId(),tabId4);
}
Program: 171743
Project: 171743
Buggy source:
private void adjustTextSize(int newCount){
  final float oldRatio=(this.count < MAX_VISIBLE_TABS && this.count >= 10) ? TWO_DIGITS_SIZE_RATIO : ONE_DIGIT_SIZE_RATIO;
  final float newRatio=(newCount < MAX_VISIBLE_TABS && newCount >= 10) ? TWO_DIGITS_SIZE_RATIO : ONE_DIGIT_SIZE_RATIO;
  if (this.count == 0 || newRatio != oldRatio) {
    final int sizeInPixel=(int)(box.getWidth() * newRatio);
    if (sizeInPixel > 0) {
      text.setTextSize(TypedValue.COMPLEX_UNIT_PX,sizeInPixel);
    }
  }
}

Fixed version (ground truth):
private void adjustTextSize(int newCount){
  final float newRatio=(newCount < MAX_VISIBLE_TABS && newCount >= 10) ? TWO_DIGITS_SIZE_RATIO : ONE_DIGIT_SIZE_RATIO;
  if (newRatio != currentTextRatio) {
    currentTextRatio=newRatio;
    text.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
      @Override public void onGlobalLayout(){
        text.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        final int sizeInPixel=(int)(box.getWidth() * newRatio);
        if (sizeInPixel > 0) {
          text.setTextSize(TypedValue.COMPLEX_UNIT_PX,sizeInPixel);
        }
      }
    }
);
  }
}
Program: 171744
Project: 171744
Buggy source:
@Override public void onAnimationEnd(Animator animation){
  finishCallback.run();
  inView.setAlpha(1f);
  if (outView != null) {
    outView.setAlpha(1f);
  }
}

Fixed version (ground truth):
@Override public void onAnimationEnd(Animator animation){
  if (finishCallback != null) {
    finishCallback.run();
  }
  inView.setAlpha(1f);
  if (outView != null) {
    outView.setAlpha(1f);
  }
}
Program: 171745
Project: 171745
Buggy source:
@Override public void onTabHoist(@NonNull final Tab tab){
  tab.detach();
  @Nullable final View outView=findExistingTabView(webViewSlot);
  webViewSlot.removeViewInLayout(outView);
  final View inView=tab.getTabView().getView();
  webViewSlot.addView(inView);
}

Fixed version (ground truth):
@Override public void onTabHoist(@NonNull final Tab tab){
  tab.detach();
  @Nullable final View outView=findExistingTabView(webViewSlot);
  webViewSlot.removeView(outView);
  final View inView=tab.getTabView().getView();
  webViewSlot.addView(inView);
  startTabTransition(null,inView,null);
}
Program: 171746
Project: 171746
Buggy source:
private void startTabTransition(@Nullable final View outView,@NonNull final View inView,final Runnable finishCallback){
  stopTabTransition();
  inView.setAlpha(0f);
  if (outView != null) {
    outView.setAlpha(1f);
  }
  int duration=inView.getResources().getInteger(R.integer.tab_transition_time);
  tabTransitionAnimator=ValueAnimator.ofFloat(0,1).setDuration(duration);
  tabTransitionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(){
    @Override public void onAnimationUpdate(    ValueAnimator animation){
      float alpha=(float)animation.getAnimatedValue();
      if (outView != null) {
        outView.setAlpha(1 - alpha);
      }
      inView.setAlpha(alpha);
    }
  }
);
  tabTransitionAnimator.addListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      finishCallback.run();
      inView.setAlpha(1f);
      if (outView != null) {
        outView.setAlpha(1f);
      }
    }
  }
);
  tabTransitionAnimator.start();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void startTabTransition(@Nullable final View outView,@NonNull final View inView,@Nullable final Runnable finishCallback){
  stopTabTransition();
  inView.setAlpha(0f);
  if (outView != null) {
    outView.setAlpha(1f);
  }
  int duration=inView.getResources().getInteger(R.integer.tab_transition_time);
  tabTransitionAnimator=ValueAnimator.ofFloat(0,1).setDuration(duration);
  tabTransitionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(){
    @Override public void onAnimationUpdate(    ValueAnimator animation){
      float alpha=(float)animation.getAnimatedValue();
      if (outView != null) {
        outView.setAlpha(1 - alpha);
      }
      inView.setAlpha(alpha);
    }
  }
);
  tabTransitionAnimator.addListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      if (finishCallback != null) {
        finishCallback.run();
      }
      inView.setAlpha(1f);
      if (outView != null) {
        outView.setAlpha(1f);
      }
    }
  }
);
  tabTransitionAnimator.start();
}
Program: 171747
Project: 171747
Buggy source:
void switchTab(int tabPosition);

Fixed version (ground truth):
void switchTab(int tabPosition,Runnable finishCallback);
Program: 171748
Project: 171748
Buggy source:
@Override public void tabClicked(int tabPosition){
  if (model.getCurrentTabPosition() != tabPosition) {
    model.switchTab(tabPosition);
  }
  view.tabSwitched(tabPosition);
}

Fixed version (ground truth):
@Override public void tabClicked(final int tabPosition){
  if (model.getCurrentTabPosition() != tabPosition) {
    model.switchTab(tabPosition,new Runnable(){
      @Override public void run(){
        view.tabSwitched(tabPosition);
      }
    }
);
  }
 else {
    view.tabSwitched(tabPosition);
  }
}
Program: 171749
Project: 171749
Buggy source:
@Override public void switchTab(int tabIdx){
  final List<Tab> tabs=tabsSession.getTabs();
  tabsSession.switchToTab(tabs.get(tabIdx).getId());
}

Fixed version (ground truth):
@Override public void switchTab(int tabIdx,final Runnable finishCallback){
  final List<Tab> tabs=tabsSession.getTabs();
  if (tabIdx < 0 || tabIdx >= tabs.size()) {
    if (BuildConfig.DEBUG) {
      throw new ArrayIndexOutOfBoundsException("String_Node_Str" + tabIdx + "String_Node_Str"+ tabs.size());
    }
    return;
  }
  tabsSession.addTabsChromeListener(new TabsChromeAdapter(){
    @Override public void onTabHoist(    @NonNull Tab tab){
      tabsSession.removeTabsChromeListener(this);
      finishCallback.run();
    }
  }
);
  tabsSession.switchToTab(tabs.get(tabIdx).getId());
}
Program: 171750
Project: 171750
Buggy source:
private void saveTabsToPersistence(){
  List<TabModel> tabModelListForPersistence=getTabsSession().getTabModelListForPersistence();
  final String currentTabId=(getTabsSession().getCurrentTab() != null) ? getTabsSession().getCurrentTab().getId() : null;
  if (tabModelListForPersistence != null && !TextUtils.isEmpty(currentTabId)) {
    TabModelStore.getInstance(this).saveTabs(this,tabModelListForPersistence,currentTabId,null);
  }
}

Fixed version (ground truth):
private void saveTabsToPersistence(){
  List<TabModel> tabModelListForPersistence=getTabsSession().getTabModelListForPersistence();
  final String currentTabId=(getTabsSession().getCurrentTab() != null) ? getTabsSession().getCurrentTab().getId() : null;
  if (tabModelListForPersistence != null) {
    TabModelStore.getInstance(this).saveTabs(this,tabModelListForPersistence,currentTabId,null);
  }
}
Program: 171751
Project: 171751
Buggy source:
public void getSavedTabs(@NonNull final Context context,final AsyncQueryListener listener){
  new QueryTabsTask(context,tabsDatabase,listener).executeOnExecutor(SERIAL_EXECUTOR);
}

Fixed version (ground truth):
public void getSavedTabs(@NonNull final Context context,@Nullable final AsyncQueryListener listener){
  new QueryTabsTask(context,tabsDatabase,listener).executeOnExecutor(SERIAL_EXECUTOR);
}
Program: 171752
Project: 171752
Buggy source:
public void saveTabs(@NonNull final Context context,@NonNull final List<TabModel> tabModelList,@NonNull final String currentTabId,final AsyncSaveListener listener){
  if (tabModelList.size() == 0) {
    if (listener != null) {
      listener.onSaveComplete();
    }
    return;
  }
  PreferenceManager.getDefaultSharedPreferences(context).edit().putString(context.getResources().getString(R.string.pref_key_current_tab_id),currentTabId).apply();
  new SaveTabsTask(tabsDatabase,listener).executeOnExecutor(SERIAL_EXECUTOR,tabModelList.toArray(new TabModel[0]));
}

Fixed version (ground truth):
public void saveTabs(@NonNull final Context context,@NonNull final List<TabModel> tabModelList,@Nullable final String currentTabId,@Nullable final AsyncSaveListener listener){
  PreferenceManager.getDefaultSharedPreferences(context).edit().putString(context.getResources().getString(R.string.pref_key_current_tab_id),currentTabId).apply();
  new SaveTabsTask(tabsDatabase,listener).executeOnExecutor(SERIAL_EXECUTOR,tabModelList.toArray(new TabModel[0]));
}
Program: 171753
Project: 171753
Buggy source:
/** 
 * To add @see{TabsChromeListener} to this session.
 * @param listener
 */
public void addTabsChromeListener(@Nullable TabsChromeListener listener){
  if (!this.tabsViewListeners.contains(listener)) {
    this.tabsChromeListeners.add(listener);
  }
}

Fixed version (ground truth):
/** 
 * To add @see{TabsChromeListener} to this session.
 * @param listener
 */
public void addTabsChromeListener(@Nullable TabsChromeListener listener){
  if (!this.tabsChromeListeners.contains(listener)) {
    this.tabsChromeListeners.add(listener);
  }
}
Program: 171755
Project: 171755
Buggy source:
public static ContentValues getContentValuesFromScreenshot(Screenshot screenshot){
  ContentValues values=new ContentValues();
  if (screenshot.getTitle() != null)   values.put(ScreenshotContract.Screenshot.TITLE,screenshot.getTitle());
  if (screenshot.getUrl() != null)   values.put(ScreenshotContract.Screenshot.URL,screenshot.getUrl());
  if (screenshot.getTimestamp() != 0)   values.put(ScreenshotContract.Screenshot.TIMESTAMP,screenshot.getTimestamp());
  if (screenshot.getImageUri() != null)   values.put(ScreenshotContract.Screenshot.IMAGE_URI,screenshot.getImageUri());
  return values;
}

Fixed version (ground truth):
public static ContentValues getContentValuesFromScreenshot(Screenshot screenshot){
  ContentValues values=new ContentValues();
  if (screenshot.getTitle() != null) {
    values.put(ScreenshotContract.Screenshot.TITLE,screenshot.getTitle());
  }
  if (screenshot.getUrl() != null) {
    values.put(ScreenshotContract.Screenshot.URL,screenshot.getUrl());
  }
  if (screenshot.getTimestamp() != 0) {
    values.put(ScreenshotContract.Screenshot.TIMESTAMP,screenshot.getTimestamp());
  }
  if (screenshot.getImageUri() != null) {
    values.put(ScreenshotContract.Screenshot.IMAGE_URI,screenshot.getImageUri());
  }
  return values;
}