Program: 153196
Project: 153196
Buggy source:
public void run(){
  while (!mExit) {
    String[] columns={PackageDbHelper.COLUMN_CODE,PackageDbHelper.COLUMN_VERSION,PackageDbHelper.COLUMN_STATE,PackageDbHelper.COLUMN_PKG_NAME};
    Cursor c=mPkgDBHelper.select(columns,null,null,null);
    Log.i(TAG,"String_Node_Str" + Integer.toString(c.getCount()));
    int codeId=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_CODE);
    int versionId=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_VERSION);
    int stateId=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_STATE);
    int pkgNameId=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_PKG_NAME);
    String code=null;
    String version=null;
    String state=null;
    String pkgName=null;
    PackageManager pm=mContext.getPackageManager();
    ArrayList<String> codes=new ArrayList<String>();
    ArrayList<String> versions=new ArrayList<String>();
    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
      code=c.getString(codeId);
      version=c.getString(versionId);
      state=c.getString(stateId);
      pkgName=c.getString(pkgNameId);
      PackageState pkgstate=Constants.getStateByString(state);
      if (pkgUninstalled(pm,pkgName,pkgstate)) {
        mPkgDBHelper.delete(code);
      }
 else       if (PackageState.install_succeeded == pkgstate) {
        codes.add(code);
        versions.add(version);
      }
    }
    c.close();
    Log.i(TAG,"String_Node_Str" + Integer.toString(codes.size()));
    HttpUtil httpUtil=new HttpUtil();
    try {
      String reqStr=UrlHelpers.getUpdateRequestString(codes,versions);
      Log.i(TAG,"String_Node_Str" + reqStr);
      String url=UrlHelpers.getUpdateUrl(mSyncService.getToken());
      Log.i(TAG,"String_Node_Str" + url);
      InputStream stream=httpUtil.httpPost(url,reqStr);
      ArrayList<AppInfo> appList=AppListParser.parse(stream,codes.size());
      Log.i(TAG,"String_Node_Str" + Integer.toString(appList.size()));
      ContentValues cv=new ContentValues();
      for (int i=0; i < appList.size(); ++i) {
        AppInfo appInfo=appList.get(i);
        cv.put(PackageDbHelper.COLUMN_STATE,PackageState.need_update.name());
        mPkgDBHelper.update(appInfo.mAppCode,cv);
      }
      if (0 < appList.size()) {
        Intent intent=new Intent(Constants.ACTION_UPDATE_STATE);
        mContext.sendBroadcast(intent);
      }
    }
 catch (    Throwable tr) {
      Log.w(TAG,"String_Node_Str" + tr.getMessage());
    }
 finally {
      httpUtil.disconnect();
    }
synchronized (mSyncObject) {
      try {
        if (!mExit) {
          mSyncObject.wait(1000 * 60 * 30);
        }
      }
 catch (      InterruptedException e) {
      }
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (!mExit) {
    Log.i(TAG,"String_Node_Str");
    Map<String,String> codesVersionMap=shouldBeCheckedAppMap();
    Log.i(TAG,"String_Node_Str" + Integer.toString(codesVersionMap.size()));
    if (0 < codesVersionMap.size()) {
      AppListParser appListParser=new AppListParser();
      String reqStr=UrlHelpers.getUpdateRequestString(codesVersionMap);
      Log.i(TAG,"String_Node_Str" + reqStr);
      try {
        String url=UrlHelpers.getUpdateUrl(mSyncService.getToken());
        ArrayList<AppInfo> appList=appListParser.getUpdateList(url,reqStr,codesVersionMap.size());
        Log.i(TAG,"String_Node_Str" + Integer.toString(appList.size()));
        ContentValues cv=new ContentValues();
        for (int i=0; i < appList.size(); ++i) {
          AppInfo appInfo=appList.get(i);
          cv.put(PackageDbHelper.COLUMN_STATE,PackageState.need_update.name());
          mPkgDBHelper.update(appInfo.mAppCode,cv);
        }
        if (0 < appList.size()) {
          Intent intent=new Intent(Constants.ACTION_UPDATE_STATE);
          mContext.sendBroadcast(intent);
        }
      }
 catch (      Throwable tr) {
        Log.w(TAG,"String_Node_Str" + tr.getMessage());
      }
 finally {
        appListParser.cancel();
      }
    }
synchronized (mSyncObject) {
      try {
        if (!mExit) {
          mSyncObject.wait(1000 * 60 * 30);
        }
      }
 catch (      InterruptedException e) {
      }
    }
  }
}