nus-yam/ex-repair huggingface dataset:
Program: 33900
Project: 33900
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final View view=inflater.inflate(R.layout.fragment_event_list_fragment_pager,container,false);
  mViewPager=(ViewPager)view.findViewById(R.id.event_pager);
  final PagerSlidingTabStrip tabs=(PagerSlidingTabStrip)view.findViewById(R.id.event_pager_tabs);
  final Context c=getActivity();
  final int mShortAnimationDuration=getResources().getInteger(android.R.integer.config_shortAnimTime);
  view.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      mViewPager.setAdapter(new EventsByWeekFragmentPagerAdapter(c,getChildFragmentManager(),mYear));
      tabs.setViewPager(mViewPager);
      int currentWeek=Event.competitionWeek(new Date());
      int week1Index=((EventsByWeekFragmentPagerAdapter)mViewPager.getAdapter()).getLabels().indexOf(String.format(Event.REGIONAL_LABEL,1));
      mViewPager.setCurrentItem(currentWeek > 10 ? Math.min(mViewPager.getAdapter().getCount(),week1Index) : currentWeek);
      view.animate().alpha(1f).setDuration(mShortAnimationDuration).setListener(null).start();
    }
  }
).start();
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  final View view=inflater.inflate(R.layout.fragment_event_list_fragment_pager,container,false);
  mViewPager=(ViewPager)view.findViewById(R.id.event_pager);
  final PagerSlidingTabStrip tabs=(PagerSlidingTabStrip)view.findViewById(R.id.event_pager_tabs);
  final Context c=getActivity();
  final int mShortAnimationDuration=getResources().getInteger(android.R.integer.config_shortAnimTime);
  mViewPager.setAdapter(new EventsByWeekFragmentPagerAdapter(c,getChildFragmentManager(),mYear));
  tabs.setViewPager(mViewPager);
  int currentWeek=Event.competitionWeek(new Date());
  int week1Index=((EventsByWeekFragmentPagerAdapter)mViewPager.getAdapter()).getLabels().indexOf(String.format(Event.REGIONAL_LABEL,1));
  mViewPager.setCurrentItem(currentWeek > 10 ? Math.min(mViewPager.getAdapter().getCount(),week1Index) : currentWeek);
  return view;
}
Program: 33903
Project: 33903
Buggy source:
@Override protected void onPostExecute(APIResponse.CODE c){
  super.onPostExecute(c);
  if (event != null && mFragment.getActivity() != null) {
    eventName.setText(event.getEventName());
    eventDate.setText(event.getDateString());
    eventLoc.setText(event.getLocation());
    if (showNextMatch) {
      nextLayout.setVisibility(View.VISIBLE);
      nextLayout.addView(next);
    }
    if (showLastMatch) {
      lastLayout.setVisibility(View.VISIBLE);
      lastLayout.addView(last);
    }
    if (showRanks) {
      topTeams.setVisibility(View.VISIBLE);
      topTeams.addView(ranks);
    }
    if (showStats) {
      topOpr.setVisibility(View.VISIBLE);
      topOpr.addView(stats);
    }
    if (c == APIResponse.CODE.OFFLINECACHE) {
      activity.showWarningMessage(activity.getString(R.string.warning_using_cached_data));
    }
    if (mFragment.getView() != null) {
      mFragment.getView().findViewById(R.id.progress).setVisibility(View.GONE);
      mFragment.getView().findViewById(R.id.event_info_container).setVisibility(View.VISIBLE);
    }
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(APIResponse.CODE c){
  super.onPostExecute(c);
  if (event != null && mFragment.getActivity() != null) {
    eventName.setText(event.getEventName());
    eventDate.setText(event.getDateString());
    eventLoc.setText(event.getLocation());
    if (showNextMatch) {
      nextLayout.setVisibility(View.VISIBLE);
      if (nextLayout.getChildCount() > 1) {
        nextLayout.removeViewAt(1);
      }
      nextLayout.addView(next);
    }
    if (showLastMatch) {
      lastLayout.setVisibility(View.VISIBLE);
      if (lastLayout.getChildCount() > 1) {
        lastLayout.removeViewAt(1);
      }
      lastLayout.addView(last);
    }
    if (showRanks) {
      topTeams.setVisibility(View.VISIBLE);
      if (topTeams.getChildCount() > 1) {
        topTeams.removeViewAt(1);
      }
      topTeams.addView(ranks);
    }
    if (showStats) {
      topOpr.setVisibility(View.VISIBLE);
      if (topOpr.getChildCount() > 1) {
        topOpr.removeViewAt(1);
      }
      topOpr.addView(stats);
    }
    if (c == APIResponse.CODE.OFFLINECACHE) {
      activity.showWarningMessage(activity.getString(R.string.warning_using_cached_data));
    }
    if (mFragment.getView() != null) {
      mFragment.getView().findViewById(R.id.progress).setVisibility(View.GONE);
      mFragment.getView().findViewById(R.id.event_info_container).setVisibility(View.VISIBLE);
    }
  }
}
Program: 33904
Project: 33904
Buggy source:
public synchronized static APIResponse<ArrayList<SimpleEvent>> getSimpleEventsInWeek(Context c,int year,int week) throws NoDataException {
  Log.d("String_Node_Str","String_Node_Str" + week);
  ArrayList<SimpleEvent> events=new ArrayList<>();
  boolean allEventsLoaded=PreferenceManager.getDefaultSharedPreferences(c).getBoolean(ALL_EVENTS_LOADED_TO_DATABASE,false);
  APIResponse<String> response=null;
  if (allEventsLoaded) {
    Log.d("String_Node_Str","String_Node_Str");
    events=Database.getInstance(c).getEventsInWeek(year,week);
  }
 else {
    response=TBAv2.getResponseFromURLOrThrow(c,"String_Node_Str" + year,false);
    events=TBAv2.getEventList(response.getData());
    Database.getInstance(c).storeEvents(events);
    events=Database.getInstance(c).getEventsInWeek(year,week);
    if (response.getCode() != APIResponse.CODE.NODATA) {
      PreferenceManager.getDefaultSharedPreferences(c).edit().putBoolean(ALL_EVENTS_LOADED_TO_DATABASE,true).commit();
    }
  }
  return new APIResponse<>(events,response == null ? APIResponse.CODE.OFFLINECACHE : response.getCode());
}

Fixed version (ground truth):
public synchronized static APIResponse<ArrayList<SimpleEvent>> getSimpleEventsInWeek(Context c,int year,int week) throws NoDataException {
  Log.d("String_Node_Str","String_Node_Str" + week);
  ArrayList<SimpleEvent> events=new ArrayList<>();
  boolean allEventsLoaded=PreferenceManager.getDefaultSharedPreferences(c).getBoolean(ALL_EVENTS_LOADED_TO_DATABASE,false);
  APIResponse<String> response;
  if (allEventsLoaded) {
    Log.d("String_Node_Str","String_Node_Str");
    events=Database.getInstance(c).getEventsInWeek(year,week);
    response=new APIResponse<>("String_Node_Str",ConnectionDetector.isConnectedToInternet(c) ? APIResponse.CODE.CACHED304 : APIResponse.CODE.OFFLINECACHE);
  }
 else {
    response=TBAv2.getResponseFromURLOrThrow(c,"String_Node_Str" + year,false);
    events=TBAv2.getEventList(response.getData());
    Database.getInstance(c).storeEvents(events);
    events=Database.getInstance(c).getEventsInWeek(year,week);
    if (response.getCode() != APIResponse.CODE.NODATA) {
      PreferenceManager.getDefaultSharedPreferences(c).edit().putBoolean(ALL_EVENTS_LOADED_TO_DATABASE,true).commit();
    }
  }
  return new APIResponse<>(events,response.getCode());
}
Program: 33905
Project: 33905
Buggy source:
public synchronized static APIResponse<ArrayList<SimpleTeam>> getSimpleTeamsInRange(Context c,int lowerBound,int upperBound) throws NoDataException {
  Log.d("String_Node_Str","String_Node_Str" + lowerBound + "String_Node_Str"+ upperBound);
  ArrayList<SimpleTeam> teams=new ArrayList<>();
  boolean allTeamsLoaded=PreferenceManager.getDefaultSharedPreferences(c).getBoolean(ALL_TEAMS_LOADED_TO_DATABASE,false);
  APIResponse<String> response=null;
  if (allTeamsLoaded) {
    teams=Database.getInstance(c).getTeamsInRange(lowerBound,upperBound);
  }
 else {
    final String URL="String_Node_Str" + Constants.getApiHeader();
    response=TBAv2.getResponseFromURLOrThrow(c,URL,false);
    Log.d("String_Node_Str","String_Node_Str");
    teams=CSVManager.parseTeamsFromCSV(response.getData());
    Log.d("String_Node_Str","String_Node_Str");
    Log.d("String_Node_Str","String_Node_Str");
    Database.getInstance(c).storeTeams(teams);
    Log.d("String_Node_Str","String_Node_Str");
    teams=Database.getInstance(c).getTeamsInRange(lowerBound,upperBound);
    if (response.getCode() != APIResponse.CODE.NODATA) {
      PreferenceManager.getDefaultSharedPreferences(c).edit().putBoolean(ALL_TEAMS_LOADED_TO_DATABASE,true).commit();
    }
  }
  return new APIResponse<>(teams,response == null ? APIResponse.CODE.OFFLINECACHE : response.getCode());
}

Fixed version (ground truth):
public synchronized static APIResponse<ArrayList<SimpleTeam>> getSimpleTeamsInRange(Context c,int lowerBound,int upperBound) throws NoDataException {
  Log.d("String_Node_Str","String_Node_Str" + lowerBound + "String_Node_Str"+ upperBound);
  ArrayList<SimpleTeam> teams=new ArrayList<>();
  boolean allTeamsLoaded=PreferenceManager.getDefaultSharedPreferences(c).getBoolean(ALL_TEAMS_LOADED_TO_DATABASE,false);
  APIResponse<String> response;
  if (allTeamsLoaded) {
    teams=Database.getInstance(c).getTeamsInRange(lowerBound,upperBound);
    response=new APIResponse<>("String_Node_Str",ConnectionDetector.isConnectedToInternet(c) ? APIResponse.CODE.CACHED304 : APIResponse.CODE.OFFLINECACHE);
  }
 else {
    final String URL="String_Node_Str" + Constants.getApiHeader();
    response=TBAv2.getResponseFromURLOrThrow(c,URL,false);
    Log.d("String_Node_Str","String_Node_Str");
    teams=CSVManager.parseTeamsFromCSV(response.getData());
    Log.d("String_Node_Str","String_Node_Str");
    Log.d("String_Node_Str","String_Node_Str");
    Database.getInstance(c).storeTeams(teams);
    Log.d("String_Node_Str","String_Node_Str");
    teams=Database.getInstance(c).getTeamsInRange(lowerBound,upperBound);
    if (response.getCode() != APIResponse.CODE.NODATA) {
      PreferenceManager.getDefaultSharedPreferences(c).edit().putBoolean(ALL_TEAMS_LOADED_TO_DATABASE,true).commit();
    }
  }
  return new APIResponse<>(teams,response.getCode());
}
Program: 33906
Project: 33906
Buggy source:
@Override protected Void doInBackground(String... params){
  eventKey=params[0];
  awards=new ArrayList<>();
  keys=new ArrayList<>();
  ArrayList<Award> awardList=null;
  try {
    awardList=DataManager.getEventAwards(mFragment.getActivity(),eventKey);
    for (    Award a : awardList) {
      ArrayList<AwardListElement> allWinners=a.renderAll();
      awards.addAll(allWinners);
      for (int i=0; i < allWinners.size(); i++) {
        keys.add(a.getEventKey() + "String_Node_Str" + a.getName());
      }
    }
  }
 catch (  DataManager.NoDataException e) {
    e.printStackTrace();
  }
  adapter=new ListViewAdapter(mFragment.getActivity(),awards,keys);
  return null;
}

Fixed version (ground truth):
@Override protected Void doInBackground(String... params){
  eventKey=params[0];
  awards=new ArrayList<>();
  keys=new ArrayList<>();
  ArrayList<Award> awardList;
  try {
    awardList=DataManager.getEventAwards(mFragment.getActivity(),eventKey);
    for (    Award a : awardList) {
      ArrayList<AwardListElement> allWinners=a.renderAll();
      awards.addAll(allWinners);
      for (      AwardListElement allWinner : allWinners) {
        keys.add(a.getEventKey() + "String_Node_Str" + a.getName());
      }
    }
  }
 catch (  DataManager.NoDataException e) {
    e.printStackTrace();
  }
  adapter=new ListViewAdapter(mFragment.getActivity(),awards,keys);
  return null;
}
Program: 33907
Project: 33907
Buggy source:
@Override protected void onPostExecute(Void aVoid){
  View view=mFragment.getView();
  if (view != null) {
    ListView rankings=(ListView)view.findViewById(R.id.event_awards);
    rankings.setAdapter(adapter);
    rankings.setOnItemClickListener(this);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Void aVoid){
  View view=mFragment.getView();
  if (view != null) {
    ListView rankings=(ListView)view.findViewById(R.id.event_awards);
    rankings.setAdapter(adapter);
  }
}
Program: 33908
Project: 33908
Buggy source:
@Override protected void onPostExecute(Void v){
  super.onPostExecute(v);
  if (mFragment.getView() != null) {
    ListView eventList=(ListView)mFragment.getView().findViewById(R.id.event_list);
    eventList.setAdapter(adapter);
    eventList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> parent,      View view,      int position,      long id){
        Intent intent=new Intent(mFragment.getActivity(),ViewEventActivity.class);
        Bundle data=intent.getExtras();
        if (data == null)         data=new Bundle();
        if (view.getTag() != null) {
          data.putString("String_Node_Str",view.getTag().toString());
          intent.putExtras(data);
          mFragment.getActivity().startActivity(intent);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Void v){
  super.onPostExecute(v);
  if (mFragment.getView() != null) {
    ListView eventList=(ListView)mFragment.getView().findViewById(R.id.event_list);
    eventList.setAdapter(adapter);
  }
}
Program: 33909
Project: 33909
Buggy source:
@Override protected void onPostExecute(Void aVoid){
  View view=mFragment.getView();
  if (view != null) {
    ListView rankings=(ListView)view.findViewById(R.id.event_ranking);
    rankings.setAdapter(adapter);
    rankings.setOnItemClickListener(this);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Void aVoid){
  View view=mFragment.getView();
  if (view != null) {
    ListView rankings=(ListView)view.findViewById(R.id.event_ranking);
    rankings.setAdapter(adapter);
  }
}
Program: 33910
Project: 33910
Buggy source:
@Override protected void onPostExecute(Void aVoid){
  View view=mFragment.getView();
  if (view != null) {
    ListView stats=(ListView)view.findViewById(R.id.event_ranking);
    stats.setAdapter(adapter);
    stats.setOnItemClickListener(this);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Void aVoid){
  View view=mFragment.getView();
  if (view != null) {
    ListView stats=(ListView)view.findViewById(R.id.event_ranking);
    stats.setAdapter(adapter);
  }
}
Program: 33911
Project: 33911
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_events,null);
  mListView=(ListView)v.findViewById(R.id.event_list);
  if (mAdapter != null) {
    mListView.setAdapter(mAdapter);
    mListView.onRestoreInstanceState(mListState);
  }
 else {
    mTask=new PopulateEventList(this,mYear,mWeek,mTeamKey);
    mTask.execute();
  }
  return v;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_events,null);
  mListView=(ListView)v.findViewById(R.id.event_list);
  if (mAdapter != null) {
    mListView.setAdapter(mAdapter);
    mListView.onRestoreInstanceState(mListState);
  }
 else {
    mTask=new PopulateEventList(this,mYear,mWeek,mTeamKey);
    mTask.execute();
  }
  mListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      Intent intent=new Intent(getActivity(),ViewEventActivity.class);
      String eventKey=((ListViewAdapter)parent.getAdapter()).getKey(position);
      intent.putExtra("String_Node_Str",eventKey);
      startActivity(intent);
    }
  }
);
  return v;
}
Program: 33912
Project: 33912
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getArguments() != null) {
    mEventKey=getArguments().getString(EVENT_KEY,"String_Node_Str");
  }
  if (savedInstanceState != null && savedInstanceState.containsKey(EVENT_KEY)) {
    mEventKey=savedInstanceState.getString(EVENT_KEY);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getArguments() != null) {
    mEventKey=getArguments().getString(EVENT_KEY,"String_Node_Str");
  }
}
Program: 33913
Project: 33913
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_event_awards,null);
  mListView=(ListView)view.findViewById(R.id.event_awards);
  if (mAdapter != null) {
    mListView.setAdapter(mAdapter);
    mListView.onRestoreInstanceState(mListState);
  }
 else {
    mTask=new PopulateEventAwards(this);
    mTask.execute(mEventKey);
  }
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_event_awards,null);
  mListView=(ListView)view.findViewById(R.id.event_awards);
  if (mAdapter != null) {
    mListView.setAdapter(mAdapter);
    mListView.onRestoreInstanceState(mListState);
  }
 else {
    mTask=new PopulateEventAwards(this);
    mTask.execute(mEventKey);
  }
  mListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      String eventKey=((ListViewAdapter)parent.getAdapter()).getKey(position);
      startActivity(ViewTeamActivity.newInstance(getActivity(),eventKey));
    }
  }
);
  return view;
}
Program: 33914
Project: 33914
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_event_rankings,null);
  mListView=(ListView)v.findViewById(R.id.event_ranking);
  if (mAdapter != null) {
    mListView.setAdapter(mAdapter);
    mListView.onRestoreInstanceState(mListState);
  }
 else {
    mTask=new PopulateEventRankings(this);
    mTask.execute(eventKey);
  }
  return v;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_event_rankings,null);
  mListView=(ListView)v.findViewById(R.id.event_ranking);
  if (mAdapter != null) {
    mListView.setAdapter(mAdapter);
    mListView.onRestoreInstanceState(mListState);
  }
 else {
    mTask=new PopulateEventRankings(this);
    mTask.execute(eventKey);
  }
  mListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      String eventKey=((ListViewAdapter)parent.getAdapter()).getKey(position);
      startActivity(ViewTeamActivity.newInstance(getActivity(),eventKey));
    }
  }
);
  return v;
}
Program: 33916
Project: 33916
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  if (position == mCurrentSelectedNavigationItemPosition) {
    mDrawerLayout.closeDrawer(mDrawerList);
    return;
  }
  mDrawerList.setSelection(position);
  switchToModeForPosition(position);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  if (position == mCurrentSelectedNavigationItemPosition) {
    mDrawerLayout.closeDrawer(mDrawerList);
    return;
  }
  switchToModeForPosition(position);
}
Program: 33917
Project: 33917
Buggy source:
private void switchToModeForPosition(int position){
  Fragment fragment;
switch (position) {
default :
case 0:
    fragment=new EventsByWeekFragment();
  setupActionBarForEvents();
break;
case 1:
fragment=new AllTeamsListFragment();
setupActionBarForTeams();
break;
case 2:
fragment=new InsightsFragment();
setupActionBarForInsights();
break;
case 3:
startActivity(new Intent(this,SettingsActivity.class));
mDrawerLayout.closeDrawer(mDrawerList);
return;
}
mDrawerList.setSelection(position);
fragment.setRetainInstance(true);
getSupportFragmentManager().beginTransaction().replace(R.id.container,fragment,MAIN_FRAGMENT_TAG).commit();
mDrawerList.setItemChecked(position,true);
mCurrentSelectedNavigationItemPosition=position;
mDrawerLayout.closeDrawer(mDrawerList);
}

Fixed version (ground truth):
private void switchToModeForPosition(int position){
  Fragment fragment;
switch (position) {
default :
case 0:
    fragment=new EventsByWeekFragment();
  setupActionBarForEvents();
break;
case 1:
fragment=new AllTeamsListFragment();
setupActionBarForTeams();
break;
case 2:
fragment=new InsightsFragment();
setupActionBarForInsights();
break;
case 3:
startActivity(new Intent(this,SettingsActivity.class));
mDrawerList.setItemChecked(mCurrentSelectedNavigationItemPosition,true);
mDrawerLayout.closeDrawer(mDrawerList);
return;
}
mDrawerList.setItemChecked(position,true);
((NavigationDrawerAdapter)mDrawerList.getAdapter()).setItemSelected(position);
fragment.setRetainInstance(true);
getSupportFragmentManager().beginTransaction().replace(R.id.container,fragment,MAIN_FRAGMENT_TAG).commit();
mCurrentSelectedNavigationItemPosition=position;
mDrawerLayout.closeDrawer(mDrawerList);
}
Program: 33918
Project: 33918
Buggy source:
@Override public View getView(Context c,LayoutInflater inflater,View convertView){
  if (convertView == null) {
    convertView=inflater.inflate(layout,null);
  }
  if (icon != -1) {
    ((ImageView)convertView.findViewById(R.id.icon)).setImageResource(icon);
  }
  TextView textView=((TextView)convertView.findViewById(R.id.title));
  textView.setText(title);
  if (convertView.isActivated()) {
    textView.setTypeface(null,Typeface.BOLD);
  }
 else {
    textView.setTypeface(null,Typeface.NORMAL);
  }
  return convertView;
}

Fixed version (ground truth):
@Override public View getView(Context c,LayoutInflater inflater,View convertView){
  if (convertView == null) {
    convertView=inflater.inflate(layout,null);
  }
  if (icon != -1) {
    ((ImageView)convertView.findViewById(R.id.icon)).setImageResource(icon);
  }
  TextView textView=((TextView)convertView.findViewById(R.id.title));
  textView.setText(title);
  return convertView;
}
Program: 33919
Project: 33919
Buggy source:
public String getDateString(){
  return renderDateFormat.format(startDate) + "String_Node_Str" + renderDateFormat.format(endDate);
}

Fixed version (ground truth):
public String getDateString(){
  return shortRenderDateFormat.format(startDate) + "String_Node_Str" + renderDateFormat.format(endDate);
}
Program: 33920
Project: 33920
Buggy source:
@Override public void actionBarSpinnerSelected(int position,String yearString){
  int year=Integer.parseInt(yearString);
  if (year == mYear) {
    return;
  }
  mYear=year;
  View view=getView();
  ViewPager pager=(ViewPager)view.findViewById(R.id.event_pager);
  pager.setAdapter(new EventsByWeekFragmentPagerAdapter(getChildFragmentManager(),mYear));
  PagerSlidingTabStrip tabs=(PagerSlidingTabStrip)view.findViewById(R.id.event_pager_tabs);
  tabs.setViewPager(pager);
}

Fixed version (ground truth):
@Override public void actionBarSpinnerSelected(int position,String yearString){
  int year=Integer.parseInt(yearString);
  if (year == mYear) {
    return;
  }
  mYear=year;
  final View view=getView();
  final ViewPager pager=(ViewPager)view.findViewById(R.id.event_pager);
  final PagerSlidingTabStrip tabs=(PagerSlidingTabStrip)view.findViewById(R.id.event_pager_tabs);
  final int mShortAnimationDuration=getResources().getInteger(android.R.integer.config_shortAnimTime);
  view.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      pager.setAdapter(new EventsByWeekFragmentPagerAdapter(getChildFragmentManager(),mYear));
      tabs.setViewPager(pager);
      view.animate().alpha(1f).setDuration(mShortAnimationDuration).setListener(null).start();
    }
  }
).start();
}
Program: 33923
Project: 33923
Buggy source:
/** 
 * From org.apache.solr.search.QueryUtils 
 */
public void deleteDocument(DeleteRequest deleteRequest) throws Exception {
  indexLock.readLock().lock();
  try {
    String uniqueId=deleteRequest.getUniqueId();
    ReadWriteLock documentLock=documentLockHandler.getLock(uniqueId);
    try {
      documentLock.writeLock().lock();
      if (deleteRequest.getDeleteDocument()) {
        LumongoSegment s=findSegmentFromUniqueId(deleteRequest.getUniqueId());
        s.deleteDocument(uniqueId);
        documentStorage.deleteSourceDocument(uniqueId);
      }
      if (deleteRequest.getDeleteAllAssociated()) {
        documentStorage.deleteAssociatedDocuments(uniqueId);
      }
 else       if (deleteRequest.hasFilename()) {
        String fileName=deleteRequest.getFilename();
        documentStorage.deleteAssociatedDocument(uniqueId,fileName);
      }
    }
  finally {
      documentLock.writeLock().unlock();
    }
  }
  finally {
    indexLock.readLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * From org.apache.solr.search.QueryUtils 
 */
public void deleteDocument(DeleteRequest deleteRequest) throws Exception {
  indexLock.readLock().lock();
  try {
    String uniqueId=deleteRequest.getUniqueId();
    ReadWriteLock documentLock=documentLockHandler.getLock(uniqueId);
    try {
      documentLock.writeLock().lock();
      if (deleteRequest.getDeleteDocument()) {
        LumongoSegment s=findSegmentFromUniqueId(deleteRequest.getUniqueId());
        s.deleteDocument(uniqueId);
        if (indexConfig.getIndexSettings().getStoreDocumentInMongo()) {
          documentStorage.deleteSourceDocument(uniqueId);
        }
      }
      if (deleteRequest.getDeleteAllAssociated()) {
        documentStorage.deleteAssociatedDocuments(uniqueId);
      }
 else       if (deleteRequest.hasFilename()) {
        String fileName=deleteRequest.getFilename();
        documentStorage.deleteAssociatedDocument(uniqueId,fileName);
      }
    }
  finally {
      documentLock.writeLock().unlock();
    }
  }
  finally {
    indexLock.readLock().unlock();
  }
}
Program: 33925
Project: 33925
Buggy source:
public void addTerm(Lumongo.Term.Builder term){
  Lumongo.Term.Builder lmTerm=tokenCount.get(term.getValue());
  if (lmTerm == null) {
    tokenCount.put(term.getValue(),term);
  }
 else {
    lmTerm.setTermFreq(lmTerm.getTermFreq() + term.getTermFreq());
  }
}

Fixed version (ground truth):
public void addTerm(Lumongo.Term.Builder term){
  Lumongo.Term.Builder lmTerm=tokenCount.get(term.getValue());
  if (lmTerm == null) {
    lmTerm=Lumongo.Term.newBuilder(term.buildPartial());
    tokenCount.put(term.getValue(),lmTerm);
  }
 else {
    lmTerm.setTermFreq(lmTerm.getTermFreq() + term.getTermFreq());
  }
}
Program: 33926
Project: 33926
Buggy source:
private void openReaderIfChanges() throws IOException {
  DirectoryReader newDirectoryReader=DirectoryReader.openIfChanged(directoryReader,indexWriter,indexConfig.getApplyUncommittedDeletes());
  if (newDirectoryReader != null) {
    QueryResultCache qrc=queryResultCache;
    if (qrc != null) {
      qrc.clear();
    }
    directoryReader=newDirectoryReader;
  }
}

Fixed version (ground truth):
private void openReaderIfChanges() throws IOException {
  DirectoryReader newDirectoryReader=DirectoryReader.openIfChanged(directoryReader,indexWriter,indexConfig.getApplyUncommittedDeletes());
  if (newDirectoryReader != null) {
    directoryReader=newDirectoryReader;
    QueryResultCache qrc=queryResultCache;
    if (qrc != null) {
      qrc.clear();
    }
  }
}
Program: 33930
Project: 33930
Buggy source:
public void deleteDocument(String uniqueId) throws Exception {
  Term term=new Term(uniqueIdField,uniqueId);
  indexWriter.deleteDocuments(term);
  possibleCommit();
}

Fixed version (ground truth):
public void deleteDocument(String uniqueId) throws Exception {
  Term term=new Term(uniqueIdField,uniqueId);
  indexWriter.deleteDocuments(term);
  if (indexConfig.getApplyUncommitedDeletes()) {
    queryResultCache.clear();
  }
  possibleCommit();
}
Program: 33931
Project: 33931
Buggy source:
public MongoDirectory(MongoClient mongo,String ddName,String indexName,boolean sharded,int blockSize) throws MongoException, IOException {
  this.mongo=mongo;
  this.dbname=ddName;
  this.indexName=indexName;
  this.blockSize=blockSize;
synchronized (MongoDirectory.class) {
    String key=ddName + "String_Node_Str" + indexName;
    Short indexNumber=indexNameToNumberMap.get(key);
    if (indexNumber == null) {
      indexNameToNumberMap.put(key,indexCount);
      indexCount++;
      indexNumber=indexCount;
    }
    this.indexNumber=indexNumber;
  }
  getFilesCollection().createIndex(new Document(FILE_NUMBER,1));
  Document indexes=new Document();
  indexes.put(FILE_NUMBER,1);
  indexes.put(BLOCK_NUMBER,1);
  getBlocksCollection().createIndex(indexes);
  if (sharded) {
    String blockCollectionName=getBlocksCollection().getNamespace().getFullName();
    MongoDatabase db=mongo.getDatabase(MongoConstants.StandardDBs.ADMIN);
    Document shardCommand=new Document();
    shardCommand.put(MongoConstants.Commands.SHARD_COLLECTION,blockCollectionName);
    shardCommand.put(MongoConstants.Commands.SHARD_KEY,indexes);
    db.runCommand(shardCommand);
  }
  nameToFileMap=new ConcurrentHashMap<>();
  fetchInitialContents();
}

Fixed version (ground truth):
public MongoDirectory(MongoClient mongo,String ddName,String indexName,boolean sharded,int blockSize) throws MongoException, IOException {
  this.mongo=mongo;
  this.dbname=ddName;
  this.indexName=indexName;
  this.blockSize=blockSize;
synchronized (MongoDirectory.class) {
    String key=ddName + "String_Node_Str" + indexName;
    Short indexNumber=indexNameToNumberMap.get(key);
    if (indexNumber == null) {
      indexNameToNumberMap.put(key,indexCount);
      indexNumber=indexCount;
      indexCount++;
    }
    this.indexNumber=indexNumber;
  }
  getFilesCollection().createIndex(new Document(FILE_NUMBER,1));
  Document indexes=new Document();
  indexes.put(FILE_NUMBER,1);
  indexes.put(BLOCK_NUMBER,1);
  getBlocksCollection().createIndex(indexes);
  if (sharded) {
    String blockCollectionName=getBlocksCollection().getNamespace().getFullName();
    MongoDatabase db=mongo.getDatabase(MongoConstants.StandardDBs.ADMIN);
    Document shardCommand=new Document();
    shardCommand.put(MongoConstants.Commands.SHARD_COLLECTION,blockCollectionName);
    shardCommand.put(MongoConstants.Commands.SHARD_KEY,indexes);
    db.runCommand(shardCommand);
  }
  nameToFileMap=new ConcurrentHashMap<>();
  fetchInitialContents();
}
Program: 33933
Project: 33933
Buggy source:
@GET @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) public Response get(@Context Response response,@QueryParam(LumongoConstants.UNIQUE_ID) final String uniqueId,@QueryParam(LumongoConstants.INDEX) final String indexName){
  Lumongo.FetchRequest.Builder fetchRequest=Lumongo.FetchRequest.newBuilder();
  fetchRequest.setIndexName(indexName);
  fetchRequest.setUniqueId(uniqueId);
  Lumongo.FetchResponse fetchResponse;
  try {
    fetchResponse=indexManager.fetch(fetchRequest.build());
    if (fetchResponse.hasResultDocument()) {
      Lumongo.ResultDocument resultDocument=fetchResponse.getResultDocument();
      ByteString bs=resultDocument.getDocument();
      DBObject document=new BasicDBObject();
      document.putAll(BSON.decode(bs.toByteArray()));
      return Response.status(LumongoConstants.SUCCESS).entity(document.toString()).build();
    }
 else {
      return Response.status(LumongoConstants.NOT_FOUND).entity("String_Node_Str" + uniqueId + "String_Node_Str"+ indexName+ "String_Node_Str").build();
    }
  }
 catch (  Exception e) {
    return Response.status(LumongoConstants.INTERNAL_ERROR).entity(e.getMessage()).build();
  }
}

Fixed version (ground truth):
@GET @Produces({MediaType.APPLICATION_JSON}) public Response get(@Context Response response,@QueryParam(LumongoConstants.UNIQUE_ID) final String uniqueId,@QueryParam(LumongoConstants.INDEX) final String indexName){
  Lumongo.FetchRequest.Builder fetchRequest=Lumongo.FetchRequest.newBuilder();
  fetchRequest.setIndexName(indexName);
  fetchRequest.setUniqueId(uniqueId);
  Lumongo.FetchResponse fetchResponse;
  try {
    fetchResponse=indexManager.fetch(fetchRequest.build());
    if (fetchResponse.hasResultDocument()) {
      Lumongo.ResultDocument resultDocument=fetchResponse.getResultDocument();
      ByteString bs=resultDocument.getDocument();
      DBObject document=new BasicDBObject();
      document.putAll(BSON.decode(bs.toByteArray()));
      return Response.status(LumongoConstants.SUCCESS).entity(document.toString()).build();
    }
 else {
      return Response.status(LumongoConstants.NOT_FOUND).entity("String_Node_Str" + uniqueId + "String_Node_Str"+ indexName+ "String_Node_Str").build();
    }
  }
 catch (  Exception e) {
    return Response.status(LumongoConstants.INTERNAL_ERROR).entity("String_Node_Str" + uniqueId + "String_Node_Str"+ indexName+ "String_Node_Str"+ e.getMessage()).build();
  }
}
Program: 33934
Project: 33934
Buggy source:
public void start() throws IOException {
  URI baseUri=UriBuilder.fromUri("String_Node_Str").port(restPort).build();
  ResourceConfig config=new ResourceConfig();
  config.register(new AssociatedResource(indexManager));
  config.register(new QueryResource(indexManager));
  server=GrizzlyHttpServerFactory.createHttpServer(baseUri,config);
}

Fixed version (ground truth):
public void start() throws IOException {
  URI baseUri=UriBuilder.fromUri("String_Node_Str").port(restPort).build();
  ResourceConfig config=new ResourceConfig();
  config.register(new AssociatedResource(indexManager));
  config.register(new QueryResource(indexManager));
  config.register(new FetchResource(indexManager));
  server=GrizzlyHttpServerFactory.createHttpServer(baseUri,config);
}
Program: 33935
Project: 33935
Buggy source:
public void populate(T newInstance,DBObject savedDBObject) throws Exception {
  Object value=savedDBObject.get(fieldName);
  boolean valuesIsList=value instanceof List;
  if (valuesIsList) {
    if (fieldIsList) {
      field.set(newInstance,new ArrayList<>((List<?>)value));
    }
 else {
      List<?> valueList=(List<?>)value;
      if (valueList.size() == 1) {
        Object first=valueList.iterator().next();
        if (first != null) {
          field.set(newInstance,first);
        }
      }
 else       if (valueList.isEmpty()) {
      }
 else {
        throw new Exception("String_Node_Str" + valueList + "String_Node_Str"+ field.getName()+ "String_Node_Str"+ field.getType()+ "String_Node_Str");
      }
    }
  }
 else {
    if (fieldIsList) {
      if (value != null) {
        field.set(newInstance,Arrays.asList(value));
      }
    }
 else {
      field.set(newInstance,value);
    }
  }
}

Fixed version (ground truth):
public void populate(T newInstance,DBObject savedDBObject) throws Exception {
  Object value=savedDBObject.get(fieldName);
  boolean valuesIsList=value instanceof List;
  if (valuesIsList) {
    if (fieldIsList) {
      field.set(newInstance,new ArrayList<>((List<?>)value));
    }
 else {
      List<?> valueList=(List<?>)value;
      if (valueList.size() == 1) {
        Object first=valueList.iterator().next();
        if (first != null) {
          field.set(newInstance,first);
        }
      }
 else       if (valueList.isEmpty()) {
      }
 else {
        throw new Exception("String_Node_Str" + valueList + "String_Node_Str"+ field.getName()+ "String_Node_Str"+ field.getType()+ "String_Node_Str");
      }
    }
  }
 else {
    if (fieldIsList) {
      if (value != null) {
        field.set(newInstance,new ArrayList<>(Arrays.asList(value)));
      }
    }
 else {
      field.set(newInstance,value);
    }
  }
}
Program: 33936
Project: 33936
Buggy source:
public BatchFetchResult fetch(Collection<ScoredResult> scoredResults) throws Exception {
  List<FetchResult> resultsFromCache=new ArrayList<FetchResult>();
  List<FetchDocument> fetchDocumentList=new ArrayList<FetchDocument>();
  for (  ScoredResult sr : scoredResults) {
    FetchResult fetchResult=documentCache.getIfPresent(sr.getUniqueId());
    boolean fetch=fetchNeeded(fetchResult,sr.getTimestamp());
    if (fetch) {
      fetchDocumentList.add(new FetchDocument(sr.getUniqueId(),sr.getIndexName()));
    }
 else {
      resultsFromCache.add(fetchResult);
    }
  }
  if (!fetchDocumentList.isEmpty()) {
    BatchFetchResult bfr=lumongoWorkPool.batchFetch(new BatchFetch().addFetches(fetchDocumentList));
    for (    FetchResult fr : bfr.getFetchResults()) {
      if (fr.hasResultDocument()) {
        documentCache.put(new DocId(fr.getUniqueId(),fr.getIndexName()),fr);
      }
    }
    bfr.getFetchResults().addAll(resultsFromCache);
    return bfr;
  }
 else {
    return new BatchFetchResult(resultsFromCache);
  }
}

Fixed version (ground truth):
public BatchFetchResult fetch(Collection<ScoredResult> scoredResults) throws Exception {
  List<FetchResult> resultsFromCache=new ArrayList<FetchResult>();
  List<FetchDocument> fetchDocumentList=new ArrayList<FetchDocument>();
  for (  ScoredResult sr : scoredResults) {
    FetchResult fetchResult=documentCache.getIfPresent(new DocId(sr.getUniqueId(),sr.getIndexName()));
    boolean fetch=fetchNeeded(fetchResult,sr.getTimestamp());
    if (fetch) {
      fetchDocumentList.add(new FetchDocument(sr.getUniqueId(),sr.getIndexName()));
    }
 else {
      resultsFromCache.add(fetchResult);
    }
  }
  if (!fetchDocumentList.isEmpty()) {
    BatchFetchResult bfr=lumongoWorkPool.batchFetch(new BatchFetch().addFetches(fetchDocumentList));
    for (    FetchResult fr : bfr.getFetchResults()) {
      if (fr.hasResultDocument()) {
        documentCache.put(new DocId(fr.getUniqueId(),fr.getIndexName()),fr);
      }
    }
    bfr.getFetchResults().addAll(resultsFromCache);
    return bfr;
  }
 else {
    return new BatchFetchResult(resultsFromCache);
  }
}
Program: 33937
Project: 33937
Buggy source:
@Override public void store(RpcController controller,StoreRequest request,RpcCallback<StoreResponse> done){
  try {
    StoreResponse sr=indexManger.storeDocument(request);
    done.run(sr);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + request + "String_Node_Str"+ e.getClass().getSimpleName()+ "String_Node_Str",e);
    controller.setFailed(e.getMessage());
    controller.startCancel();
    done.run(null);
  }
}

Fixed version (ground truth):
@Override public void store(RpcController controller,StoreRequest request,RpcCallback<StoreResponse> done){
  try {
    StoreResponse sr=indexManger.storeDocument(request);
    done.run(sr);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + request + "String_Node_Str"+ e.getClass().getSimpleName()+ "String_Node_Str",e);
    controller.setFailed(e.getMessage());
    done.run(null);
  }
}
Program: 33939
Project: 33939
Buggy source:
@Override public IndexCreateRequest getRequest(){
  IndexCreateRequest.Builder indexCreateRequestBuilder=IndexCreateRequest.newBuilder();
  if (indexName != null) {
    indexCreateRequestBuilder.setIndexName(indexName);
  }
  if (numberOfSegments != null) {
    indexCreateRequestBuilder.setNumberOfSegments(numberOfSegments);
  }
  if (uniqueIdField != null) {
    indexCreateRequestBuilder.setUniqueIdField(uniqueIdField);
  }
  if (indexSettings != null) {
    indexCreateRequestBuilder.setIndexSettings(indexSettings);
  }
  return indexCreateRequestBuilder.build();
}

Fixed version (ground truth):
@Override public IndexCreateRequest getRequest(){
  IndexCreateRequest.Builder indexCreateRequestBuilder=IndexCreateRequest.newBuilder();
  if (indexName != null) {
    indexCreateRequestBuilder.setIndexName(indexName);
  }
  if (numberOfSegments != null) {
    indexCreateRequestBuilder.setNumberOfSegments(numberOfSegments);
  }
  if (uniqueIdField != null) {
    indexCreateRequestBuilder.setUniqueIdField(uniqueIdField);
  }
  if (indexSettings != null) {
    indexCreateRequestBuilder.setIndexSettings(indexSettings);
  }
  if (faceted != null) {
    indexCreateRequestBuilder.setFaceted(faceted);
  }
  return indexCreateRequestBuilder.build();
}
Program: 33940
Project: 33940
Buggy source:
@Override public FetchRequest getRequest(){
  FetchRequest.Builder fetchRequestBuilder=FetchRequest.newBuilder();
  if (uniqueId != null) {
    fetchRequestBuilder.setUniqueId(uniqueId);
  }
  if (fileName != null) {
    fetchRequestBuilder.setFileName(fileName);
  }
  if (resultFetchType != null) {
    fetchRequestBuilder.setResultFetchType(FetchType.NONE);
  }
  if (associatedFetchType != null) {
    fetchRequestBuilder.setAssociatedFetchType(FetchType.FULL);
  }
  return fetchRequestBuilder.build();
}

Fixed version (ground truth):
@Override public FetchRequest getRequest(){
  FetchRequest.Builder fetchRequestBuilder=FetchRequest.newBuilder();
  if (uniqueId != null) {
    fetchRequestBuilder.setUniqueId(uniqueId);
  }
  if (fileName != null) {
    fetchRequestBuilder.setFileName(fileName);
  }
  if (resultFetchType != null) {
    fetchRequestBuilder.setResultFetchType(resultFetchType);
  }
  if (associatedFetchType != null) {
    fetchRequestBuilder.setAssociatedFetchType(associatedFetchType);
  }
  return fetchRequestBuilder.build();
}
Program: 33941
Project: 33941
Buggy source:
@Override public QueryRequest getRequest(){
  QueryRequest.Builder requestBuilder=QueryRequest.newBuilder();
  requestBuilder.setAmount(amount);
  requestBuilder.setQuery(query);
  if (realTime != null) {
    requestBuilder.setRealTime(realTime);
  }
  if (lastResult != null) {
    requestBuilder.setLastResult(lastResult.getLastResult());
  }
  for (  String index : indexes) {
    requestBuilder.addIndex(index);
  }
  FacetRequest.Builder facetRequestBuilder=FacetRequest.newBuilder();
  facetRequestBuilder.addAllDrillDown(drillDowns);
  facetRequestBuilder.addAllCountRequest(countRequests);
  requestBuilder.setFacetRequest(facetRequestBuilder.build());
  SortRequest.Builder sortRequestBuilder=SortRequest.newBuilder();
  sortRequestBuilder.addAllFieldSort(fieldSorts);
  requestBuilder.setSortRequest(sortRequestBuilder.build());
  return requestBuilder.build();
}

Fixed version (ground truth):
@Override public QueryRequest getRequest(){
  QueryRequest.Builder requestBuilder=QueryRequest.newBuilder();
  requestBuilder.setAmount(amount);
  requestBuilder.setQuery(query);
  if (realTime != null) {
    requestBuilder.setRealTime(realTime);
  }
  if (lastResult != null) {
    requestBuilder.setLastResult(lastResult.getLastResult());
  }
  for (  String index : indexes) {
    requestBuilder.addIndex(index);
  }
  if (!drillDowns.isEmpty() || !countRequests.isEmpty()) {
    FacetRequest.Builder facetRequestBuilder=FacetRequest.newBuilder();
    facetRequestBuilder.addAllDrillDown(drillDowns);
    facetRequestBuilder.addAllCountRequest(countRequests);
    requestBuilder.setFacetRequest(facetRequestBuilder.build());
  }
  SortRequest.Builder sortRequestBuilder=SortRequest.newBuilder();
  sortRequestBuilder.addAllFieldSort(fieldSorts);
  requestBuilder.setSortRequest(sortRequestBuilder.build());
  return requestBuilder.build();
}
Program: 33945
Project: 33945
Buggy source:
public <R>R execute(Command<R> command){
  for (int i=0; i <= retries; i++) {
    LumongoConnection lumongoConnection=null;
    LMMember randomMember=null;
    try {
      int randomMemberIndex=(int)(Math.random() * members.size());
      randomMember=members.get(randomMemberIndex);
      lumongoConnection=connectionPool.borrowObject(randomMember);
      return command.execute(lumongoConnection);
    }
 catch (    Exception e) {
      if (randomMember != null && lumongoConnection != null) {
        try {
          connectionPool.invalidateObject(randomMember,lumongoConnection);
        }
 catch (        Exception e1) {
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public <R>R execute(Command<R> command){
  for (int i=0; i <= retries; i++) {
    LumongoConnection lumongoConnection=null;
    LMMember randomMember=null;
    try {
      int randomMemberIndex=(int)(Math.random() * members.size());
      randomMember=members.get(randomMemberIndex);
      lumongoConnection=connectionPool.borrowObject(randomMember);
      R r=command.execute(lumongoConnection);
      connectionPool.returnObject(randomMember,lumongoConnection);
      return r;
    }
 catch (    Exception e) {
      if (randomMember != null && lumongoConnection != null) {
        try {
          connectionPool.invalidateObject(randomMember,lumongoConnection);
        }
 catch (        Exception e1) {
        }
      }
    }
  }
  return null;
}
Program: 33946
Project: 33946
Buggy source:
public void unloadSegment(int segmentNumber) throws CorruptIndexException, IOException {
  indexLock.writeLock().lock();
  try {
    ILock hzLock=hazelLockMap.get(segmentNumber);
    try {
      if (segmentMap.containsKey(segmentNumber)) {
        Segment s=segmentMap.remove(segmentNumber);
        if (s != null) {
          log.info("String_Node_Str" + segmentNumber + "String_Node_Str"+ indexName+ "String_Node_Str");
          s.close();
          log.info("String_Node_Str" + segmentNumber + "String_Node_Str"+ indexName+ "String_Node_Str");
          log.info("String_Node_Str" + (new TreeSet<Integer>(segmentMap.keySet())) + "String_Node_Str"+ indexName+ "String_Node_Str");
        }
      }
    }
  finally {
      try {
        hzLock.unlock();
        hzLock.forceUnlock();
        log.info("String_Node_Str" + indexName + "String_Node_Str"+ segmentNumber+ "String_Node_Str");
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + segmentNumber + "String_Node_Str");
      }
    }
  }
  finally {
    indexLock.writeLock().unlock();
  }
}

Fixed version (ground truth):
public void unloadSegment(int segmentNumber) throws CorruptIndexException, IOException {
  indexLock.writeLock().lock();
  try {
    ILock hzLock=hazelLockMap.get(segmentNumber);
    try {
      if (segmentMap.containsKey(segmentNumber)) {
        Segment s=segmentMap.remove(segmentNumber);
        if (s != null) {
          log.info("String_Node_Str" + segmentNumber + "String_Node_Str"+ indexName+ "String_Node_Str");
          s.close();
          log.info("String_Node_Str" + segmentNumber + "String_Node_Str"+ indexName+ "String_Node_Str");
          log.info("String_Node_Str" + (new TreeSet<Integer>(segmentMap.keySet())) + "String_Node_Str"+ indexName+ "String_Node_Str");
        }
      }
    }
  finally {
      try {
        hzLock.forceUnlock();
        log.info("String_Node_Str" + indexName + "String_Node_Str"+ segmentNumber+ "String_Node_Str");
      }
 catch (      Exception e) {
        log.error("String_Node_Str" + segmentNumber + "String_Node_Str",e);
      }
    }
  }
  finally {
    indexLock.writeLock().unlock();
  }
}
Program: 33947
Project: 33947
Buggy source:
@Override public void onRangeChange(RangeChangeEvent event){
  Range range=event.getNewRange();
  final int start=range.getStart();
  final int length=range.getLength();
  lastRequest.setAmount(start + length);
  searchService.search(lastRequest,new AsyncCallback<SearchResults>(){
    @Override public void onFailure(    Throwable caught){
    }
    @Override public void onSuccess(    SearchResults result){
      docCellTable.setRowCount((int)result.getTotalHits());
      docCellTable.setRowData(start,result.getDocuments().subList(start,start + length));
    }
  }
);
}

Fixed version (ground truth):
@Override public void onRangeChange(RangeChangeEvent event){
  Range range=event.getNewRange();
  final int start=range.getStart();
  final int length=range.getLength();
  lastRequest.setAmount(start + length);
  searchService.search(lastRequest,new AsyncCallback<SearchResults>(){
    @Override public void onFailure(    Throwable caught){
    }
    @Override public void onSuccess(    SearchResults result){
      docCellTable.setRowCount((int)result.getTotalHits());
      if (result.getDocuments().isEmpty()) {
        List<Document> emptyDocs=Collections.emptyList();
        docCellTable.setRowData(start,emptyDocs);
      }
 else {
        docCellTable.setRowData(start,result.getDocuments().subList(start,start + length));
      }
    }
  }
);
}