nus-yam/ex-repair huggingface dataset:
Program: 60718
Project: 60718
Buggy source:
private void drawEndlessProgress(Canvas canvas){
  double indicatorHeight=getDimension(R.dimen.layer_padding);
  int bottom=(int)(getMeasuredHeight() - indicatorHeight);
  if (mProgressBar == null) {
    mProgressBar=new ProgressBar(this);
    mProgressBar.setBounds(0,bottom,getMeasuredWidth(),getMeasuredHeight());
    mProgressBar.setColorScheme(mColor1,mColor2,mColor3,mColor4);
    mProgressBar.start();
  }
  if (getProgress() > 0) {
    mProgressBar.draw(canvas);
  }
}

Fixed version (ground truth):
private void drawEndlessProgress(Canvas canvas){
  if (mProgressBar == null) {
    mProgressBar=new ProgressBar(this);
    setupProgressBarBounds();
    mProgressBar.setColorScheme(mColor1,mColor2,mColor3,mColor4);
    mProgressBar.start();
  }
  if (getProgress() > 0) {
    mProgressBar.draw(canvas);
  }
}
Program: 60719
Project: 60719
Buggy source:
/** 
 * Set the View's background. Masks the API changes made in Jelly Bean.
 * @param drawable
 */
@SuppressWarnings("String_Node_Str") @SuppressLint("String_Node_Str") public void setBackgroundCompat(Drawable drawable){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    setBackground(drawable);
  }
 else {
    setBackgroundDrawable(drawable);
  }
}

Fixed version (ground truth):
/** 
 * Set the View's background. Masks the API changes made in Jelly Bean.
 * @param drawable
 */
@SuppressWarnings("String_Node_Str") @SuppressLint("String_Node_Str") public void setBackgroundCompat(Drawable drawable){
  int pL=getPaddingLeft();
  int pT=getPaddingTop();
  int pR=getPaddingRight();
  int pB=getPaddingBottom();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    setBackground(drawable);
  }
 else {
    setBackgroundDrawable(drawable);
  }
  setPadding(pL,pT,pR,pB);
}
Program: 60720
Project: 60720
Buggy source:
public void start(final ProcessButton button){
  final Handler handler=new Handler();
  handler.postDelayed(new Runnable(){
    @Override public void run(){
      mProgress+=10;
      button.setProgress(mProgress);
      if (mProgress <= 110) {
        handler.postDelayed(this,generateDelay());
      }
 else {
        mListener.onComplete();
      }
    }
  }
,generateDelay());
}

Fixed version (ground truth):
public void start(final ProcessButton button){
  final Handler handler=new Handler();
  handler.postDelayed(new Runnable(){
    @Override public void run(){
      mProgress+=10;
      button.setProgress(mProgress);
      if (mProgress < 100) {
        handler.postDelayed(this,generateDelay());
      }
 else {
        mListener.onComplete();
      }
    }
  }
,generateDelay());
}
Program: 60721
Project: 60721
Buggy source:
@Override public void run(){
  mProgress+=10;
  button.setProgress(mProgress);
  if (mProgress <= 110) {
    handler.postDelayed(this,generateDelay());
  }
 else {
    mListener.onComplete();
  }
}

Fixed version (ground truth):
@Override public void run(){
  mProgress+=10;
  button.setProgress(mProgress);
  if (mProgress < 100) {
    handler.postDelayed(this,generateDelay());
  }
 else {
    mListener.onComplete();
  }
}
Program: 60722
Project: 60722
Buggy source:
private void init(Context context,AttributeSet attrs){
  if (attrs != null) {
    initAttributes(context,attrs);
  }
  setBackgroundDrawable(getDrawable(R.drawable.btn_selector));
}

Fixed version (ground truth):
private void init(Context context,AttributeSet attrs){
  StateListDrawable states=new StateListDrawable();
  if (attrs != null) {
    initAttributes(context,attrs,states);
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    setBackground(states);
  }
 else {
    setBackgroundDrawable(states);
  }
}
Program: 60723
Project: 60723
Buggy source:
private void initAttributes(Context context,AttributeSet attributeSet){
  TypedArray attr=getTypedArray(context,attributeSet,R.styleable.FlatButton);
  if (attr == null) {
    return;
  }
  try {
    GradientDrawable drawablePressed=getGradientDrawable(R.drawable.rect_pressed);
    if (attr.hasValue(R.styleable.FlatButton_colorPressed)) {
      drawablePressed.setColor(getColor(attr,R.styleable.FlatButton_colorPressed));
    }
    LayerDrawable drawableNormal=(LayerDrawable)getDrawable(R.drawable.rect_normal);
    GradientDrawable drawableTop=(GradientDrawable)drawableNormal.getDrawable(0);
    GradientDrawable drawableBottom=(GradientDrawable)drawableNormal.getDrawable(1);
    if (attr.hasValue(R.styleable.FlatButton_colorNormal)) {
      drawableBottom.setColor(getColor(attr,R.styleable.FlatButton_colorNormal));
    }
    if (attr.hasValue(R.styleable.FlatButton_colorPressed)) {
      drawableTop.setColor(getColor(attr,R.styleable.FlatButton_colorPressed));
    }
  }
  finally {
    attr.recycle();
  }
}

Fixed version (ground truth):
private void initAttributes(Context context,AttributeSet attributeSet,StateListDrawable states){
  TypedArray attr=getTypedArray(context,attributeSet,R.styleable.FlatButton);
  if (attr == null) {
    return;
  }
  try {
    GradientDrawable drawablePressed=(GradientDrawable)getGradientDrawable(R.drawable.rect_pressed).mutate();
    if (attr.hasValue(R.styleable.FlatButton_colorPressed)) {
      drawablePressed.setColor(getColor(attr,R.styleable.FlatButton_colorPressed));
    }
    LayerDrawable drawableNormal=(LayerDrawable)getDrawable(R.drawable.rect_normal).mutate();
    ;
    GradientDrawable drawableTop=(GradientDrawable)drawableNormal.getDrawable(0).mutate();
    ;
    GradientDrawable drawableBottom=(GradientDrawable)drawableNormal.getDrawable(1).mutate();
    ;
    if (attr.hasValue(R.styleable.FlatButton_colorNormal)) {
      drawableBottom.setColor(getColor(attr,R.styleable.FlatButton_colorNormal));
    }
    if (attr.hasValue(R.styleable.FlatButton_colorPressed)) {
      drawableTop.setColor(getColor(attr,R.styleable.FlatButton_colorPressed));
    }
    states.addState(new int[]{android.R.attr.state_pressed},drawablePressed);
    states.addState(new int[]{},drawableNormal);
  }
  finally {
    attr.recycle();
  }
}
Program: 60724
Project: 60724
Buggy source:
private void init(Context context,AttributeSet attrs){
  mMinProgress=0;
  mMaxProgress=100;
  mProgressDrawable=getGradientDrawable(R.drawable.rect_progress);
  mCompleteDrawable=getGradientDrawable(R.drawable.rect_complete);
  if (attrs != null) {
    initAttributes(context,attrs);
  }
}

Fixed version (ground truth):
private void init(Context context,AttributeSet attrs){
  mMinProgress=0;
  mMaxProgress=100;
  mProgressDrawable=(GradientDrawable)getGradientDrawable(R.drawable.rect_progress).mutate();
  mCompleteDrawable=(GradientDrawable)getGradientDrawable(R.drawable.rect_complete).mutate();
  if (attrs != null) {
    initAttributes(context,attrs);
  }
}
Program: 60725
Project: 60725
Buggy source:
@Override public Job call() throws Exception {
  int retries=20;
  int attempts=0;
  Set<String> retryableExceptions=ImmutableSet.of(RuntimeException.class.getName());
  Set<String> retryableExceptionMessages=ImmutableSet.of("String_Node_Str","String_Node_Str");
  while (true) {
    attempts++;
    try {
      return doExecute();
    }
 catch (    ExecutionFailureException e) {
      QueryError error=e.getJob().getError();
      FailureInfo failureInfo=(error == null) ? null : error.getFailureInfo();
      if ((failureInfo == null) || !retryableExceptions.contains(failureInfo.getType()) || !Iterables.any(retryableExceptionMessages,new StringContainsSubstringPredicate(failureInfo.getMessage()))|| !(retries > attempts)) {
        throw e;
      }
      job.setError(null);
      job.setState(JobState.QUEUED);
      updateJobInfo(job.getTablesUsed(),job.getColumns(),job.getQueryStats(),null,null,Collections.<List<Object>>emptyList(),true);
      log.info("String_Node_Str",error.toString());
    }
  }
}

Fixed version (ground truth):
@Override public Job call() throws Exception {
  int retries=20;
  int attempts=0;
  Set<String> retryableExceptions=ImmutableSet.of(RuntimeException.class.getName());
  Set<String> retryableExceptionMessages=ImmutableSet.of("String_Node_Str","String_Node_Str");
  while (!isCancelled) {
    attempts++;
    try {
      return doExecute();
    }
 catch (    ExecutionFailureException e) {
      QueryError error=e.getJob().getError();
      FailureInfo failureInfo=(error == null) ? null : error.getFailureInfo();
      if ((failureInfo == null) || !retryableExceptions.contains(failureInfo.getType()) || !Iterables.any(retryableExceptionMessages,new StringContainsSubstringPredicate(failureInfo.getMessage()))|| !(retries > attempts)) {
        throw e;
      }
      job.setError(null);
      job.setState(JobState.QUEUED);
      updateJobInfo(job.getTablesUsed(),job.getColumns(),job.getQueryStats(),null,null,Collections.<List<Object>>emptyList(),true);
      log.info("String_Node_Str",error.toString());
    }
  }
  return job;
}
Program: 60727
Project: 60727
Buggy source:
protected void jobFinished(Job job){
  job.setQueryFinished(new DateTime());
  historyStore.addRun(job);
  for (  Table t : job.getTablesUsed()) {
    usageStore.markUsage(t);
  }
  if (job.getOutput() instanceof HiveTablePersistentOutput) {
    String[] parts=job.getOutput().getLocation().toString().split("String_Node_Str");
    if (parts.length == 2) {
      Map<String,List<String>> cache=schemaCache.getSchemaMap("String_Node_Str");
      List<String> tables=cache.get(parts[0]);
      tables.add(parts[1]);
    }
  }
  eventBus.post(new JobFinishedEvent(job));
}

Fixed version (ground truth):
protected void jobFinished(Job job){
  job.setQueryFinished(new DateTime());
  historyStore.addRun(job);
  for (  Table t : job.getTablesUsed()) {
    usageStore.markUsage(t);
  }
  if (job.getOutput() instanceof HiveTablePersistentOutput) {
    String[] parts=job.getOutput().getLocation().toString().split("String_Node_Str");
    if (parts.length == 2) {
      Map<String,List<String>> cache=schemaCache.getSchemaMap("String_Node_Str");
      List<String> tables=cache.get(parts[0]);
      tables.add(parts[1]);
    }
  }
  eventBus.post(new JobFinishedEvent(job));
  executionMap.remove(job.getUuid());
}
Program: 60728
Project: 60728
Buggy source:
@Override public List<Job> getRecentlyRun(long maxResults,Iterable<Table> tables){
  try {
    String tablesClause=format("String_Node_Str",Util.getTableCondition(tables));
    return getJobs(maxResults,1,tablesClause);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}

Fixed version (ground truth):
@Override public List<Job> getRecentlyRun(long maxResults,Iterable<Table> tables){
  try {
    String tablesClause=Util.getTableCondition(tables);
    return getJobs(maxResults,1,tablesClause,null);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}
Program: 60729
Project: 60729
Buggy source:
@Override public List<Job> getRecentlyRunForUser(String user,long maxResults,Iterable<Table> tables){
  try {
    String tablesClause=format("String_Node_Str",user,Util.getTableCondition(tables));
    return getJobs(maxResults,1,tablesClause);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}

Fixed version (ground truth):
@Override public List<Job> getRecentlyRunForUser(String user,long maxResults,Iterable<Table> tables){
  try {
    String usersClause=format("String_Node_Str",user);
    String tablesClause=Util.getTableCondition(tables);
    return getJobs(maxResults,1,tablesClause,usersClause);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}
Program: 60730
Project: 60730
Buggy source:
private List<Job> getJobs(long limit,int dayInterval){
  return getJobs(limit,dayInterval,"String_Node_Str");
}

Fixed version (ground truth):
private List<Job> getJobs(long limit,int dayInterval){
  return getJobs(limit,dayInterval,null,null);
}
Program: 60731
Project: 60731
Buggy source:
@Inject public QueriesResource(JobHistoryStore jobHistoryStore){
  this.jobHistoryStore=jobHistoryStore;
}

Fixed version (ground truth):
@Inject public QueriesResource(JobHistoryStore jobHistoryStore,ExecutionClient executionClient){
  this.jobHistoryStore=jobHistoryStore;
  this.executionClient=executionClient;
}
Program: 60732
Project: 60732
Buggy source:
@GET @Path("String_Node_Str") public Response getUserQueries(@Auth AirpalUser user,@PathParam("String_Node_Str") String userId,@QueryParam("String_Node_Str") int numResults,@QueryParam("String_Node_Str") List<PartitionedTable> tables){
  Iterable<Job> recentlyRun;
  int results=Optional.of(numResults).or(200);
  if (tables.size() < 1) {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results);
  }
 else {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results,Iterables.transform(tables,new PartitionedTableToTable()));
  }
  ImmutableList.Builder<Job> filtered=ImmutableList.builder();
  for (  Job job : recentlyRun) {
    if (job.getTablesUsed().isEmpty() && (job.getState() == JobState.FAILED)) {
      filtered.add(job);
      continue;
    }
    for (    Table table : job.getTablesUsed()) {
      if (AuthorizationUtil.isAuthorizedRead(user,table)) {
        filtered.add(new Job(job.getUser(),job.getQuery(),job.getUuid(),job.getOutput(),job.getQueryStats(),job.getState(),Collections.<Column>emptyList(),Collections.<Table>emptySet(),job.getQueryStartedDateTime(),job.getError(),job.getQueryFinishedDateTime()));
      }
    }
  }
  List<Job> sortedResult=Ordering.natural().nullsLast().onResultOf(JOB_ORDERING).reverse().immutableSortedCopy(filtered.build());
  return Response.ok(sortedResult).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response getUserQueries(@Auth AirpalUser user,@PathParam("String_Node_Str") String userId,@QueryParam("String_Node_Str") int numResults,@QueryParam("String_Node_Str") List<PartitionedTable> tables){
  Iterable<Job> recentlyRun;
  int results=Optional.of(numResults).or(0);
  if (results <= 0) {
    results=100;
  }
  if (tables.size() < 1) {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results);
  }
 else {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results,Iterables.transform(tables,new PartitionedTableToTable()));
  }
  ImmutableList.Builder<Job> filtered=ImmutableList.builder();
  for (  Job job : recentlyRun) {
    if (job.getTablesUsed().isEmpty() && (job.getState() == JobState.FAILED)) {
      filtered.add(job);
      continue;
    }
    for (    Table table : job.getTablesUsed()) {
      if (AuthorizationUtil.isAuthorizedRead(user,table)) {
        filtered.add(new Job(job.getUser(),job.getQuery(),job.getUuid(),job.getOutput(),job.getQueryStats(),job.getState(),Collections.<Column>emptyList(),Collections.<Table>emptySet(),job.getQueryStartedDateTime(),job.getError(),job.getQueryFinishedDateTime()));
      }
    }
  }
  List<Job> sortedResult=Ordering.natural().nullsLast().onResultOf(JOB_ORDERING).reverse().immutableSortedCopy(filtered.build());
  return Response.ok(sortedResult).build();
}
Program: 60733
Project: 60733
Buggy source:
public AirpalUser getUser(Subject subject){
  Object principal=subject.getPrincipal();
  if (principal instanceof AirpalUser) {
    return (AirpalUser)principal;
  }
 else   if (principal instanceof String) {
    return new AirpalUserImpl((String)principal,defaultSchema,defaultQueryTimeout,defaultAccessLevel,subject);
  }
 else   if (principal instanceof ToAirpalUser) {
    return ((ToAirpalUser)principal).toAirpalUser(subject);
  }
 else {
    throw new IllegalArgumentException(format("String_Node_Str",principal));
  }
}

Fixed version (ground truth):
public AirpalUser getUser(Subject subject){
  Object principal=subject.getPrincipal();
  if (principal instanceof ToAirpalUser) {
    return ((ToAirpalUser)principal).toAirpalUser(subject);
  }
 else   if (principal instanceof String) {
    return new AirpalUserImpl((String)principal,defaultSchema,defaultQueryTimeout,defaultAccessLevel,subject);
  }
 else   if (principal instanceof AirpalUser) {
    return (AirpalUser)principal;
  }
 else {
    throw new IllegalArgumentException(format("String_Node_Str",principal));
  }
}
Program: 60735
Project: 60735
Buggy source:
@Override public void addRun(Job job){
  JobDAO jobDAO=dbi.onDemand(JobDAO.class);
  TableDAO tableDAO=dbi.onDemand(TableDAO.class);
  JobTableDAO jobTableDAO=dbi.onDemand(JobTableDAO.class);
  JobOutputDAO jobOutputDAO=dbi.onDemand(JobOutputDAO.class);
  long jobId=jobDAO.createJob(job);
  Set<TableRow> tablesInDb=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  Sets.SetView<Table> tablesToAdd=Sets.difference(job.getTablesUsed(),Sets.newHashSet(Iterables.transform(tablesInDb,TableRow.MAP_TO_TABLE)));
  tableDAO.createTables(tablesToAdd);
  Set<TableRow> tablesWithIds=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  List<JobTableRow> jobTableRows=new ArrayList<>(job.getTablesUsed().size());
  for (  TableRow tableRow : tablesWithIds) {
    jobTableRows.add(new JobTableRow(-1,jobId,tableRow.getId()));
  }
  jobTableDAO.createJobTables(jobTableRows);
  jobOutputDAO.createJobOutput(job.getOutput(),jobId);
}

Fixed version (ground truth):
@Override public void addRun(Job job){
  JobDAO jobDAO=dbi.onDemand(JobDAO.class);
  TableDAO tableDAO=dbi.onDemand(TableDAO.class);
  JobTableDAO jobTableDAO=dbi.onDemand(JobTableDAO.class);
  JobOutputDAO jobOutputDAO=dbi.onDemand(JobOutputDAO.class);
  long jobId=jobDAO.createJob(job);
  Set<TableRow> tablesInDb=Collections.emptySet();
  if (job.getTablesUsed().size() > 0) {
    tablesInDb=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  }
  Sets.SetView<Table> tablesToAdd=Sets.difference(job.getTablesUsed(),Sets.newHashSet(Iterables.transform(tablesInDb,TableRow.MAP_TO_TABLE)));
  tableDAO.createTables(tablesToAdd);
  Set<TableRow> tablesWithIds=Collections.emptySet();
  if (job.getTablesUsed().size() > 0) {
    tablesWithIds=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  }
  List<JobTableRow> jobTableRows=new ArrayList<>(job.getTablesUsed().size());
  for (  TableRow tableRow : tablesWithIds) {
    jobTableRows.add(new JobTableRow(-1,jobId,tableRow.getId()));
  }
  jobTableDAO.createJobTables(jobTableRows);
  if (job.getOutput().getLocation() != null) {
    jobOutputDAO.createJobOutput(job.getOutput(),jobId);
  }
}
Program: 60736
Project: 60736
Buggy source:
@Override public SavedQuery map(int index,ResultSet r,StatementContext ctx) throws SQLException {
  try {
    return new UserSavedQuery(objectMapper.readValue(r.getString("String_Node_Str"),FeaturedQuery.QueryWithPlaceholders.class),r.getString("String_Node_Str"),r.getString("String_Node_Str"),r.getString("String_Node_Str"),null,UUID.fromString(r.getString("String_Node_Str")),false);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
@Override public SavedQuery map(int index,ResultSet r,StatementContext ctx) throws SQLException {
  try {
    return new UserSavedQuery(objectMapper.readValue(r.getString("String_Node_Str"),FeaturedQuery.QueryWithPlaceholders.class),r.getString("String_Node_Str"),r.getString("String_Node_Str"),r.getString("String_Node_Str"),null,UUID.fromString(r.getString("String_Node_Str")),false);
  }
 catch (  IOException e) {
    log.error("String_Node_Str",e);
  }
  return null;
}
Program: 60737
Project: 60737
Buggy source:
@Override public Job call() throws Exception {
  int retries=20;
  int attempts=0;
  Set<String> retryableExceptions=ImmutableSet.of(RuntimeException.class.getName());
  Set<String> retryableExceptionMessages=ImmutableSet.of("String_Node_Str","String_Node_Str");
  while (true) {
    attempts++;
    try {
      return doExecute();
    }
 catch (    ExecutionFailureException e) {
      QueryError error=e.getJob().getError();
      FailureInfo failureInfo=(error == null) ? null : error.getFailureInfo();
      if ((failureInfo == null) || !retryableExceptions.contains(failureInfo.getType()) || !Iterables.any(retryableExceptionMessages,new StringContainsSubstringPredicate(failureInfo.getMessage()))|| !(retries > attempts)) {
        throw e;
      }
      job.setError(null);
      job.setState(JobState.QUEUED);
      updateJobInfo(job.getTablesUsed(),job.getColumns(),job.getQueryStats(),null,null,Collections.<List<Object>>emptyList(),true);
      log.info("String_Node_Str",error.toString());
    }
  }
}

Fixed version (ground truth):
@Override public Job call() throws Exception {
  int retries=20;
  int attempts=0;
  Set<String> retryableExceptions=ImmutableSet.of(RuntimeException.class.getName());
  Set<String> retryableExceptionMessages=ImmutableSet.of("String_Node_Str","String_Node_Str");
  while (!isCancelled) {
    attempts++;
    try {
      return doExecute();
    }
 catch (    ExecutionFailureException e) {
      QueryError error=e.getJob().getError();
      FailureInfo failureInfo=(error == null) ? null : error.getFailureInfo();
      if ((failureInfo == null) || !retryableExceptions.contains(failureInfo.getType()) || !Iterables.any(retryableExceptionMessages,new StringContainsSubstringPredicate(failureInfo.getMessage()))|| !(retries > attempts)) {
        throw e;
      }
      job.setError(null);
      job.setState(JobState.QUEUED);
      updateJobInfo(job.getTablesUsed(),job.getColumns(),job.getQueryStats(),null,null,Collections.<List<Object>>emptyList(),true);
      log.info("String_Node_Str",error.toString());
    }
  }
  return job;
}
Program: 60739
Project: 60739
Buggy source:
protected void jobFinished(Job job){
  job.setQueryFinished(new DateTime());
  historyStore.addRun(job);
  for (  Table t : job.getTablesUsed()) {
    usageStore.markUsage(t);
  }
  if (job.getOutput() instanceof HiveTablePersistentOutput) {
    String[] parts=job.getOutput().getLocation().toString().split("String_Node_Str");
    if (parts.length == 2) {
      Map<String,List<String>> cache=schemaCache.getSchemaMap("String_Node_Str");
      List<String> tables=cache.get(parts[0]);
      tables.add(parts[1]);
    }
  }
  eventBus.post(new JobFinishedEvent(job));
}

Fixed version (ground truth):
protected void jobFinished(Job job){
  job.setQueryFinished(new DateTime());
  historyStore.addRun(job);
  for (  Table t : job.getTablesUsed()) {
    usageStore.markUsage(t);
  }
  if (job.getOutput() instanceof HiveTablePersistentOutput) {
    String[] parts=job.getOutput().getLocation().toString().split("String_Node_Str");
    if (parts.length == 2) {
      Map<String,List<String>> cache=schemaCache.getSchemaMap("String_Node_Str");
      List<String> tables=cache.get(parts[0]);
      tables.add(parts[1]);
    }
  }
  eventBus.post(new JobFinishedEvent(job));
  executionMap.remove(job.getUuid());
}
Program: 60740
Project: 60740
Buggy source:
@Override public List<Job> getRecentlyRun(long maxResults,Iterable<Table> tables){
  try {
    String tablesClause=format("String_Node_Str",Util.getTableCondition(tables));
    return getJobs(maxResults,1,tablesClause);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}

Fixed version (ground truth):
@Override public List<Job> getRecentlyRun(long maxResults,Iterable<Table> tables){
  try {
    String tablesClause=Util.getTableCondition(tables);
    return getJobs(maxResults,1,tablesClause,null);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}
Program: 60741
Project: 60741
Buggy source:
@Override public List<Job> getRecentlyRunForUser(String user,long maxResults,Iterable<Table> tables){
  try {
    String tablesClause=format("String_Node_Str",user,Util.getTableCondition(tables));
    return getJobs(maxResults,1,tablesClause);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}

Fixed version (ground truth):
@Override public List<Job> getRecentlyRunForUser(String user,long maxResults,Iterable<Table> tables){
  try {
    String usersClause=format("String_Node_Str",user);
    String tablesClause=Util.getTableCondition(tables);
    return getJobs(maxResults,1,tablesClause,usersClause);
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Collections.emptyList();
  }
}
Program: 60742
Project: 60742
Buggy source:
private List<Job> getJobs(long limit,int dayInterval){
  return getJobs(limit,dayInterval,"String_Node_Str");
}

Fixed version (ground truth):
private List<Job> getJobs(long limit,int dayInterval){
  return getJobs(limit,dayInterval,null,null);
}
Program: 60743
Project: 60743
Buggy source:
@Inject public QueriesResource(JobHistoryStore jobHistoryStore){
  this.jobHistoryStore=jobHistoryStore;
}

Fixed version (ground truth):
@Inject public QueriesResource(JobHistoryStore jobHistoryStore,ExecutionClient executionClient){
  this.jobHistoryStore=jobHistoryStore;
  this.executionClient=executionClient;
}
Program: 60744
Project: 60744
Buggy source:
@GET @Path("String_Node_Str") public Response getUserQueries(@Auth AirpalUser user,@PathParam("String_Node_Str") String userId,@QueryParam("String_Node_Str") int numResults,@QueryParam("String_Node_Str") List<PartitionedTable> tables){
  Iterable<Job> recentlyRun;
  int results=Optional.of(numResults).or(200);
  if (tables.size() < 1) {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results);
  }
 else {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results,Iterables.transform(tables,new PartitionedTableToTable()));
  }
  ImmutableList.Builder<Job> filtered=ImmutableList.builder();
  for (  Job job : recentlyRun) {
    if (job.getTablesUsed().isEmpty() && (job.getState() == JobState.FAILED)) {
      filtered.add(job);
      continue;
    }
    for (    Table table : job.getTablesUsed()) {
      if (AuthorizationUtil.isAuthorizedRead(user,table)) {
        filtered.add(new Job(job.getUser(),job.getQuery(),job.getUuid(),job.getOutput(),job.getQueryStats(),job.getState(),Collections.<Column>emptyList(),Collections.<Table>emptySet(),job.getQueryStartedDateTime(),job.getError(),job.getQueryFinishedDateTime()));
      }
    }
  }
  List<Job> sortedResult=Ordering.natural().nullsLast().onResultOf(JOB_ORDERING).reverse().immutableSortedCopy(filtered.build());
  return Response.ok(sortedResult).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response getUserQueries(@Auth AirpalUser user,@PathParam("String_Node_Str") String userId,@QueryParam("String_Node_Str") int numResults,@QueryParam("String_Node_Str") List<PartitionedTable> tables){
  Iterable<Job> recentlyRun;
  int results=Optional.of(numResults).or(0);
  if (results <= 0) {
    results=100;
  }
  if (tables.size() < 1) {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results);
  }
 else {
    recentlyRun=jobHistoryStore.getRecentlyRunForUser(userId,results,Iterables.transform(tables,new PartitionedTableToTable()));
  }
  ImmutableList.Builder<Job> filtered=ImmutableList.builder();
  for (  Job job : recentlyRun) {
    if (job.getTablesUsed().isEmpty() && (job.getState() == JobState.FAILED)) {
      filtered.add(job);
      continue;
    }
    for (    Table table : job.getTablesUsed()) {
      if (AuthorizationUtil.isAuthorizedRead(user,table)) {
        filtered.add(new Job(job.getUser(),job.getQuery(),job.getUuid(),job.getOutput(),job.getQueryStats(),job.getState(),Collections.<Column>emptyList(),Collections.<Table>emptySet(),job.getQueryStartedDateTime(),job.getError(),job.getQueryFinishedDateTime()));
      }
    }
  }
  List<Job> sortedResult=Ordering.natural().nullsLast().onResultOf(JOB_ORDERING).reverse().immutableSortedCopy(filtered.build());
  return Response.ok(sortedResult).build();
}
Program: 60745
Project: 60745
Buggy source:
public AirpalUser getUser(Subject subject){
  Object principal=subject.getPrincipal();
  if (principal instanceof AirpalUser) {
    return (AirpalUser)principal;
  }
 else   if (principal instanceof String) {
    return new AirpalUserImpl((String)principal,defaultSchema,defaultQueryTimeout,defaultAccessLevel,subject);
  }
 else   if (principal instanceof ToAirpalUser) {
    return ((ToAirpalUser)principal).toAirpalUser(subject);
  }
 else {
    throw new IllegalArgumentException(format("String_Node_Str",principal));
  }
}

Fixed version (ground truth):
public AirpalUser getUser(Subject subject){
  Object principal=subject.getPrincipal();
  if (principal instanceof ToAirpalUser) {
    return ((ToAirpalUser)principal).toAirpalUser(subject);
  }
 else   if (principal instanceof String) {
    return new AirpalUserImpl((String)principal,defaultSchema,defaultQueryTimeout,defaultAccessLevel,subject);
  }
 else   if (principal instanceof AirpalUser) {
    return (AirpalUser)principal;
  }
 else {
    throw new IllegalArgumentException(format("String_Node_Str",principal));
  }
}
Program: 60747
Project: 60747
Buggy source:
@Override public void addRun(Job job){
  JobDAO jobDAO=dbi.onDemand(JobDAO.class);
  TableDAO tableDAO=dbi.onDemand(TableDAO.class);
  JobTableDAO jobTableDAO=dbi.onDemand(JobTableDAO.class);
  JobOutputDAO jobOutputDAO=dbi.onDemand(JobOutputDAO.class);
  long jobId=jobDAO.createJob(job);
  Set<TableRow> tablesInDb=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  Sets.SetView<Table> tablesToAdd=Sets.difference(job.getTablesUsed(),Sets.newHashSet(Iterables.transform(tablesInDb,TableRow.MAP_TO_TABLE)));
  tableDAO.createTables(tablesToAdd);
  Set<TableRow> tablesWithIds=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  List<JobTableRow> jobTableRows=new ArrayList<>(job.getTablesUsed().size());
  for (  TableRow tableRow : tablesWithIds) {
    jobTableRows.add(new JobTableRow(-1,jobId,tableRow.getId()));
  }
  jobTableDAO.createJobTables(jobTableRows);
  jobOutputDAO.createJobOutput(job.getOutput(),jobId);
}

Fixed version (ground truth):
@Override public void addRun(Job job){
  JobDAO jobDAO=dbi.onDemand(JobDAO.class);
  TableDAO tableDAO=dbi.onDemand(TableDAO.class);
  JobTableDAO jobTableDAO=dbi.onDemand(JobTableDAO.class);
  JobOutputDAO jobOutputDAO=dbi.onDemand(JobOutputDAO.class);
  long jobId=jobDAO.createJob(job);
  Set<TableRow> tablesInDb=Collections.emptySet();
  if (job.getTablesUsed().size() > 0) {
    tablesInDb=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  }
  Sets.SetView<Table> tablesToAdd=Sets.difference(job.getTablesUsed(),Sets.newHashSet(Iterables.transform(tablesInDb,TableRow.MAP_TO_TABLE)));
  tableDAO.createTables(tablesToAdd);
  Set<TableRow> tablesWithIds=Collections.emptySet();
  if (job.getTablesUsed().size() > 0) {
    tablesWithIds=new HashSet<>(tableDAO.getTables(new ArrayList<>(job.getTablesUsed())));
  }
  List<JobTableRow> jobTableRows=new ArrayList<>(job.getTablesUsed().size());
  for (  TableRow tableRow : tablesWithIds) {
    jobTableRows.add(new JobTableRow(-1,jobId,tableRow.getId()));
  }
  jobTableDAO.createJobTables(jobTableRows);
  if (job.getOutput().getLocation() != null) {
    jobOutputDAO.createJobOutput(job.getOutput(),jobId);
  }
}
Program: 60748
Project: 60748
Buggy source:
@Override public SavedQuery map(int index,ResultSet r,StatementContext ctx) throws SQLException {
  try {
    return new UserSavedQuery(objectMapper.readValue(r.getString("String_Node_Str"),FeaturedQuery.QueryWithPlaceholders.class),r.getString("String_Node_Str"),r.getString("String_Node_Str"),r.getString("String_Node_Str"),null,UUID.fromString(r.getString("String_Node_Str")),false);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
@Override public SavedQuery map(int index,ResultSet r,StatementContext ctx) throws SQLException {
  try {
    return new UserSavedQuery(objectMapper.readValue(r.getString("String_Node_Str"),FeaturedQuery.QueryWithPlaceholders.class),r.getString("String_Node_Str"),r.getString("String_Node_Str"),r.getString("String_Node_Str"),null,UUID.fromString(r.getString("String_Node_Str")),false);
  }
 catch (  IOException e) {
    log.error("String_Node_Str",e);
  }
  return null;
}
Program: 60749
Project: 60749
Buggy source:
@Override public boolean onItemClick(EasyRecyclerView parent,View view,int position,long id){
  Activity activity=getActivity2();
  EasyRecyclerView recyclerView=mRecyclerView;
  if (null == activity || null == recyclerView) {
    return false;
  }
  if (recyclerView.isInCustomChoice()) {
    recyclerView.toggleItemChecked(position);
    return true;
  }
 else {
    List<DownloadInfo> list=mList;
    if (list == null) {
      return false;
    }
    if (position < 0 && position >= list.size()) {
      return false;
    }
    Intent intent=new Intent(activity,GalleryActivity.class);
    intent.setAction(GalleryActivity.ACTION_EH);
    intent.putExtra(GalleryActivity.KEY_GALLERY_INFO,list.get(position));
    startActivity(intent);
    return true;
  }
}

Fixed version (ground truth):
@Override public boolean onItemClick(EasyRecyclerView parent,View view,int position,long id){
  Activity activity=getActivity2();
  EasyRecyclerView recyclerView=mRecyclerView;
  if (null == activity || null == recyclerView) {
    return false;
  }
  if (recyclerView.isInCustomChoice()) {
    recyclerView.toggleItemChecked(position);
    return true;
  }
 else {
    List<DownloadInfo> list=mList;
    if (list == null) {
      return false;
    }
    if (position < 0 || position >= list.size()) {
      return false;
    }
    Intent intent=new Intent(activity,GalleryActivity.class);
    intent.setAction(GalleryActivity.ACTION_EH);
    intent.putExtra(GalleryActivity.KEY_GALLERY_INFO,list.get(position));
    startActivity(intent);
    return true;
  }
}
Program: 60750
Project: 60750
Buggy source:
@Override public void onClick(View v){
  Context context=getContext2();
  Activity activity=getActivity2();
  EasyRecyclerView recyclerView=mRecyclerView;
  if (null == context || null == activity || null == recyclerView || recyclerView.isInCustomChoice()) {
    return;
  }
  List<DownloadInfo> list=mList;
  if (list == null) {
    return;
  }
  int size=list.size();
  int index=recyclerView.getChildAdapterPosition(itemView);
  if (index < 0 && index >= size) {
    return;
  }
  if (thumb == v) {
    Bundle args=new Bundle();
    args.putString(GalleryDetailScene.KEY_ACTION,GalleryDetailScene.ACTION_GALLERY_INFO);
    args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO,list.get(index));
    Announcer announcer=new Announcer(GalleryDetailScene.class).setArgs(args);
    if (ApiHelper.SUPPORT_TRANSITION) {
      announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
    }
    startScene(announcer);
  }
 else   if (start == v) {
    Intent intent=new Intent(activity,DownloadService.class);
    intent.setAction(DownloadService.ACTION_START);
    intent.putExtra(DownloadService.KEY_GALLERY_INFO,list.get(index));
    activity.startService(intent);
  }
 else   if (stop == v) {
    if (null != mDownloadManager) {
      mDownloadManager.stopDownload(list.get(index).gid);
    }
  }
}

Fixed version (ground truth):
@Override public void onClick(View v){
  Context context=getContext2();
  Activity activity=getActivity2();
  EasyRecyclerView recyclerView=mRecyclerView;
  if (null == context || null == activity || null == recyclerView || recyclerView.isInCustomChoice()) {
    return;
  }
  List<DownloadInfo> list=mList;
  if (list == null) {
    return;
  }
  int size=list.size();
  int index=recyclerView.getChildAdapterPosition(itemView);
  if (index < 0 || index >= size) {
    return;
  }
  if (thumb == v) {
    Bundle args=new Bundle();
    args.putString(GalleryDetailScene.KEY_ACTION,GalleryDetailScene.ACTION_GALLERY_INFO);
    args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO,list.get(index));
    Announcer announcer=new Announcer(GalleryDetailScene.class).setArgs(args);
    if (ApiHelper.SUPPORT_TRANSITION) {
      announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
    }
    startScene(announcer);
  }
 else   if (start == v) {
    Intent intent=new Intent(activity,DownloadService.class);
    intent.setAction(DownloadService.ACTION_START);
    intent.putExtra(DownloadService.KEY_GALLERY_INFO,list.get(index));
    activity.startService(intent);
  }
 else   if (stop == v) {
    if (null != mDownloadManager) {
      mDownloadManager.stopDownload(list.get(index).gid);
    }
  }
}
Program: 60751
Project: 60751
Buggy source:
@NonNull @Override public FavDrawerHolder onCreateViewHolder(@NonNull ViewGroup parent,int viewType){
  return new FavDrawerHolder(mInflater.inflate(R.layout.item_favorite_list,parent,false));
}

Fixed version (ground truth):
@NonNull @Override public FavDrawerHolder onCreateViewHolder(@NonNull ViewGroup parent,int viewType){
  return new FavDrawerHolder(mInflater.inflate(R.layout.item_drawer_favorites,parent,false));
}
Program: 60753
Project: 60753
Buggy source:
private void onGetFavoritesSuccess(FavoritesParser.Result result,int taskId){
  if (mHelper != null && mSearchBarMover != null && mHelper.isCurrentTask(taskId)) {
    if (mFavCatArray != null) {
      System.arraycopy(result.catArray,0,mFavCatArray,0,10);
      if (mDrawerAdapter != null) {
        mDrawerAdapter.notifyDataSetChanged();
      }
    }
    mFavCountArray=result.countArray;
    if (mFavCountArray != null) {
      mCloudSize=0;
      for (int i=0; i < 10; i++) {
        mCloudSize=mCloudSize + mFavCountArray[i];
      }
    }
    updateSearchBar();
    mHelper.setPages(taskId,result.pages);
    mHelper.onGetPageData(taskId,result.galleryInfoList);
  }
}

Fixed version (ground truth):
private void onGetFavoritesSuccess(FavoritesParser.Result result,int taskId){
  if (mHelper != null && mSearchBarMover != null && mHelper.isCurrentTask(taskId)) {
    if (mFavCatArray != null) {
      System.arraycopy(result.catArray,0,mFavCatArray,0,10);
    }
    mFavCountArray=result.countArray;
    if (mFavCountArray != null) {
      mCloudSize=0;
      for (int i=0; i < 10; i++) {
        mCloudSize=mCloudSize + mFavCountArray[i];
      }
    }
    updateSearchBar();
    mHelper.setPages(taskId,result.pages);
    mHelper.onGetPageData(taskId,result.galleryInfoList);
    if (mDrawerAdapter != null) {
      mDrawerAdapter.notifyDataSetChanged();
    }
  }
}
Program: 60754
Project: 60754
Buggy source:
@Override public void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Context context=getContext2();
  Assert.assertNotNull(context);
  mClient=EhApplication.getEhClient(context);
  mFavCatArray=Settings.getFavCat();
  if (savedInstanceState == null) {
    onInit();
  }
 else {
    onRestore(savedInstanceState);
  }
}

Fixed version (ground truth):
@Override public void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Context context=getContext2();
  Assert.assertNotNull(context);
  mClient=EhApplication.getEhClient(context);
  mFavCatArray=Settings.getFavCat();
  mFavCountArray=Settings.getFavCount();
  if (savedInstanceState == null) {
    onInit();
  }
 else {
    onRestore(savedInstanceState);
  }
}
Program: 60755
Project: 60755
Buggy source:
public AddFavoritesListener(Context context,int stageId,String sceneTag,int taskId,String keyword){
  super(context,stageId,sceneTag);
  mTaskId=taskId;
  mKeyword=keyword;
}

Fixed version (ground truth):
private AddFavoritesListener(Context context,int stageId,String sceneTag,int taskId,String keyword){
  super(context,stageId,sceneTag);
  mTaskId=taskId;
  mKeyword=keyword;
}
Program: 60756
Project: 60756
Buggy source:
public GetFavoritesListener(Context context,int stageId,String sceneTag,int taskId,boolean local,String keyword){
  super(context,stageId,sceneTag);
  mTaskId=taskId;
  mLocal=local;
  mKeyword=keyword;
}

Fixed version (ground truth):
private GetFavoritesListener(Context context,int stageId,String sceneTag,int taskId,boolean local,String keyword){
  super(context,stageId,sceneTag);
  mTaskId=taskId;
  mLocal=local;
  mKeyword=keyword;
}
Program: 60757
Project: 60757
Buggy source:
@Override public void onSuccess(FavoritesParser.Result result){
  Settings.putFavCat(result.catArray);
  FavoritesScene scene=getScene();
  if (scene != null) {
    if (mLocal) {
      scene.onGetFavoritesLocal(mKeyword,mTaskId);
    }
 else {
      scene.onGetFavoritesSuccess(result,mTaskId);
    }
  }
}

Fixed version (ground truth):
@Override public void onSuccess(FavoritesParser.Result result){
  Settings.putFavCat(result.catArray);
  Settings.putFavCount(result.countArray);
  FavoritesScene scene=getScene();
  if (scene != null) {
    if (mLocal) {
      scene.onGetFavoritesLocal(mKeyword,mTaskId);
    }
 else {
      scene.onGetFavoritesSuccess(result,mTaskId);
    }
  }
}
Program: 60759
Project: 60759
Buggy source:
@Override public boolean onTouchEvent(@NonNull MotionEvent event){
  if (mSeekBar == null) {
    return super.onTouchEvent(event);
  }
 else {
    final float offsetX=-mSeekBar.getLeft();
    final float offsetY=-mSeekBar.getTop();
    event.offsetLocation(offsetX,offsetY);
    mSeekBar.onTouchEvent(event);
    event.offsetLocation(-offsetX,-offsetY);
    return true;
  }
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(@NonNull MotionEvent event){
  if (mSeekBar == null) {
    return super.onTouchEvent(event);
  }
 else {
    View containingView=(View)mSeekBar.getParent();
    final float offsetX=-(containingView.getLeft() + mSeekBar.getLeft());
    final float offsetY=-(containingView.getTop() + mSeekBar.getTop());
    event.offsetLocation(offsetX,offsetY);
    mSeekBar.onTouchEvent(event);
    event.offsetLocation(-offsetX,-offsetY);
    return true;
  }
}
Program: 60761
Project: 60761
Buggy source:
public void write(@NonNull OutputStream os){
  OutputStreamWriter writer=null;
  try {
    writer=new OutputStreamWriter(os);
    writer.write(String.format("String_Node_Str",startPage >= 0 ? startPage : 0));
    writer.write("String_Node_Str");
    writer.write(Long.toString(gid));
    writer.write("String_Node_Str");
    writer.write(token);
    writer.write("String_Node_Str");
    writer.write("String_Node_Str");
    writer.write("String_Node_Str");
    writer.write(Integer.toString(previewPages));
    writer.write("String_Node_Str");
    writer.write(Integer.toString(previewPerPage));
    writer.write("String_Node_Str");
    writer.write(Integer.toString(pages));
    writer.write("String_Node_Str");
    for (int i=0; i < pTokenMap.size(); i++) {
      Integer key=pTokenMap.keyAt(i);
      String value=pTokenMap.valueAt(i);
      if (TOKEN_FAILED.equals(value) || TextUtils.isEmpty(value)) {
        continue;
      }
      writer.write(Integer.toString(key));
      writer.write("String_Node_Str");
      writer.write(value);
      writer.write("String_Node_Str");
    }
    writer.flush();
  }
 catch (  IOException e) {
  }
 finally {
    IOUtils.closeQuietly(writer);
    IOUtils.closeQuietly(os);
  }
}

Fixed version (ground truth):
public void write(@NonNull OutputStream os){
  OutputStreamWriter writer=null;
  try {
    writer=new OutputStreamWriter(os);
    writer.write(VERSION_STR);
    writer.write(Integer.toString(VERSION));
    writer.write("String_Node_Str");
    writer.write(String.format("String_Node_Str",startPage >= 0 ? startPage : 0));
    writer.write("String_Node_Str");
    writer.write(Long.toString(gid));
    writer.write("String_Node_Str");
    writer.write(token);
    writer.write("String_Node_Str");
    writer.write("String_Node_Str");
    writer.write("String_Node_Str");
    writer.write(Integer.toString(previewPages));
    writer.write("String_Node_Str");
    writer.write(Integer.toString(previewPerPage));
    writer.write("String_Node_Str");
    writer.write(Integer.toString(pages));
    writer.write("String_Node_Str");
    for (int i=0; i < pTokenMap.size(); i++) {
      Integer key=pTokenMap.keyAt(i);
      String value=pTokenMap.valueAt(i);
      if (TOKEN_FAILED.equals(value) || TextUtils.isEmpty(value)) {
        continue;
      }
      writer.write(Integer.toString(key));
      writer.write("String_Node_Str");
      writer.write(value);
      writer.write("String_Node_Str");
    }
    writer.flush();
  }
 catch (  IOException e) {
  }
 finally {
    IOUtils.closeQuietly(writer);
    IOUtils.closeQuietly(os);
  }
}
Program: 60762
Project: 60762
Buggy source:
private SpiderInfo readSpiderInfoFromInternet(EhConfig config){
  try {
    SpiderInfo spiderInfo=new SpiderInfo();
    spiderInfo.gid=mGalleryInfo.gid;
    spiderInfo.token=mGalleryInfo.token;
    Request request=new EhRequestBuilder(EhUrl.getGalleryDetailUrl(mGalleryInfo.gid,mGalleryInfo.token,0,false),config).build();
    Response response=mHttpClient.newCall(request).execute();
    String body=response.body().string();
    spiderInfo.pages=GalleryDetailParser.parsePages(body);
    spiderInfo.pTokenMap=new SparseArray<>(spiderInfo.pages);
    spiderInfo.previewPages=GalleryDetailParser.parsePreviewPages(body);
    readPreviews(body,spiderInfo);
    return spiderInfo;
  }
 catch (  Exception e) {
    return null;
  }
}

Fixed version (ground truth):
private SpiderInfo readSpiderInfoFromInternet(EhConfig config){
  try {
    SpiderInfo spiderInfo=new SpiderInfo();
    spiderInfo.gid=mGalleryInfo.gid;
    spiderInfo.token=mGalleryInfo.token;
    Request request=new EhRequestBuilder(EhUrl.getGalleryDetailUrl(mGalleryInfo.gid,mGalleryInfo.token,0,false),config).build();
    Response response=mHttpClient.newCall(request).execute();
    String body=response.body().string();
    spiderInfo.pages=GalleryDetailParser.parsePages(body);
    spiderInfo.pTokenMap=new SparseArray<>(spiderInfo.pages);
    readPreviews(body,0,spiderInfo);
    return spiderInfo;
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 60763
Project: 60763
Buggy source:
private void readPreviews(String body,SpiderInfo spiderInfo) throws ParseException {
  PreviewSet previewSet=GalleryDetailParser.parsePreviewSet(body);
  spiderInfo.previewPerPage=previewSet.size();
  for (int i=0, n=previewSet.size(); i < n; i++) {
    GalleryPageUrlParser.Result result=GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
    if (result != null) {
synchronized (mPTokenLock) {
        spiderInfo.pTokenMap.put(result.page,result.pToken);
      }
    }
  }
}

Fixed version (ground truth):
private void readPreviews(String body,int index,SpiderInfo spiderInfo) throws ParseException {
  spiderInfo.pages=GalleryDetailParser.parsePages(body);
  spiderInfo.previewPages=GalleryDetailParser.parsePreviewPages(body);
  PreviewSet previewSet=GalleryDetailParser.parsePreviewSet(body);
  if ((index >= 0 && index < spiderInfo.pages - 1) || (index == 0 && spiderInfo.pages == 1)) {
    spiderInfo.previewPerPage=previewSet.size();
  }
 else {
    spiderInfo.previewPerPage=Math.max(spiderInfo.previewPerPage,previewSet.size());
  }
  for (int i=0, n=previewSet.size(); i < n; i++) {
    GalleryPageUrlParser.Result result=GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
    if (result != null) {
synchronized (mPTokenLock) {
        spiderInfo.pTokenMap.put(result.page,result.pToken);
      }
    }
  }
}