nus-yam/ex-repair huggingface dataset:
Program: 34047
Project: 34047
Buggy source:
public static AlertDialog getSelectNewOwnerDialog(final Activity activity,ArrayList<String> usernameList){
  CharSequence[] listCharArray=usernameList.toArray(new CharSequence[usernameList.size()]);
  return new AlertDialog.Builder(activity).setTitle(R.string.transfer_select_title).setSingleChoiceItems(listCharArray,0,null).setPositiveButton(R.string.transfer,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      ListView listView=((AlertDialog)dialog).getListView();
      Object checkedItem=listView.getAdapter().getItem(listView.getCheckedItemPosition());
      String selectedUsername=checkedItem.toString();
      if (activity instanceof SharingActivity) {
        TransferOwnershipTask.launch(activity,SharingActivity.evercamCamera.getCameraId(),selectedUsername);
      }
    }
  }
).setNegativeButton(R.string.cancel,null).create();
}

Fixed version (ground truth):
public static AlertDialog getSelectNewOwnerDialog(final Activity activity,final ArrayList<String> usernameList){
  CharSequence[] listCharArray=usernameList.toArray(new CharSequence[usernameList.size()]);
  Builder dialogBuilder=new AlertDialog.Builder(activity).setNegativeButton(R.string.cancel,null);
  if (usernameList.size() > 0) {
    dialogBuilder.setSingleChoiceItems(listCharArray,0,null).setPositiveButton(R.string.transfer,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        ListView listView=((AlertDialog)dialog).getListView();
        Object checkedItem=listView.getAdapter().getItem(listView.getCheckedItemPosition());
        String selectedUsername=checkedItem.toString();
        if (activity instanceof SharingActivity) {
          TransferOwnershipTask.launch(activity,SharingActivity.evercamCamera.getCameraId(),selectedUsername);
        }
      }
    }
).setTitle(R.string.transfer_select_title);
  }
 else {
    dialogBuilder.setMessage(R.string.msg_share_before_transfer);
  }
  return dialogBuilder.create();
}
Program: 34048
Project: 34048
Buggy source:
public static KeenClient getClient(Context context){
  try {
    PropertyReader propertyReader=new PropertyReader(context);
    KeenClient client=new AndroidKeenClientBuilder(context).build();
    KeenProject keenProject=new KeenProject(propertyReader.getPropertyStr(PropertyReader.KEY_KEEN_PROJECT_ID),propertyReader.getPropertyStr(PropertyReader.KEY_KEEN_WRITE_KEY),propertyReader.getPropertyStr(PropertyReader.KEY_KEEN_READ_KEY));
    client.setDefaultProject(keenProject);
    return client;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
public static KeenClient getClient(Context context){
  PropertyReader propertyReader=new PropertyReader(context);
  if (propertyReader.isPropertyExist(PropertyReader.KEY_KEEN_PROJECT_ID)) {
    try {
      KeenClient client=new AndroidKeenClientBuilder(context).build();
      KeenProject keenProject=new KeenProject(propertyReader.getPropertyStr(PropertyReader.KEY_KEEN_PROJECT_ID),propertyReader.getPropertyStr(PropertyReader.KEY_KEEN_WRITE_KEY),propertyReader.getPropertyStr(PropertyReader.KEY_KEEN_READ_KEY));
      client.setDefaultProject(keenProject);
      return client;
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  return null;
}
Program: 34049
Project: 34049
Buggy source:
protected boolean deleteShare(){
  try {
    if (shareInterface instanceof CameraShare) {
      String cameraId=((CameraShare)shareInterface).getCameraId();
      String userEmail=((CameraShare)shareInterface).getUserEmail();
      return CameraShare.delete(cameraId,userEmail);
    }
 else     if (shareInterface instanceof CameraShareRequest) {
      String cameraId=((CameraShareRequest)shareInterface).getCameraId();
      String userEmail=((CameraShareRequest)shareInterface).getEmail();
      return CameraShareRequest.delete(cameraId,userEmail);
    }
  }
 catch (  EvercamException e) {
    errorMessage=e.getMessage();
  }
  return false;
}

Fixed version (ground truth):
protected boolean deleteShare(){
  try {
    if (shareInterface instanceof CameraShare) {
      String cameraId=((CameraShare)shareInterface).getCameraId();
      String userEmail=((CameraShare)shareInterface).getUserEmail();
      boolean isDeleted=CameraShare.delete(cameraId,userEmail);
      if (((CameraShare)shareInterface).getUserId().equals(AppData.defaultUser.getUsername())) {
        userDeletedSelf=true;
      }
      return isDeleted;
    }
 else     if (shareInterface instanceof CameraShareRequest) {
      String cameraId=((CameraShareRequest)shareInterface).getCameraId();
      String userEmail=((CameraShareRequest)shareInterface).getEmail();
      return CameraShareRequest.delete(cameraId,userEmail);
    }
  }
 catch (  EvercamException e) {
    errorMessage=e.getMessage();
  }
  return false;
}
Program: 34050
Project: 34050
Buggy source:
@Override protected void onPostExecute(Boolean isSuccess){
  customProgressDialog.dismiss();
  if (isSuccess) {
    CustomSnackbar.show(activity,R.string.msg_share_updated);
    FetchShareListTask.launch(SharingActivity.evercamCamera.getCameraId(),activity);
  }
 else {
    CustomToast.showInCenterLong(activity,errorMessage);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(Boolean isSuccess){
  customProgressDialog.dismiss();
  if (isSuccess) {
    if (!userDeletedSelf) {
      CustomSnackbar.show(activity,R.string.msg_share_updated);
      FetchShareListTask.launch(SharingActivity.evercamCamera.getCameraId(),activity);
    }
 else {
      if (activity instanceof SharingActivity) {
        activity.setResult(Constants.RESULT_ACCESS_REMOVED);
        activity.finish();
      }
    }
  }
 else {
    CustomToast.showInCenterLong(activity,errorMessage);
  }
}
Program: 34051
Project: 34051
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == Constants.REQUEST_CODE_PATCH_CAMERA) {
    if (resultCode == Constants.RESULT_TRUE) {
      startPlay();
    }
 else     if (resultCode == Constants.RESULT_FALSE) {
      startPlay();
    }
  }
 else {
    if (resultCode == Constants.RESULT_DELETED) {
      setResult(Constants.RESULT_TRUE);
      finish();
    }
 else     if (resultCode == Constants.RESULT_TRANSFERRED) {
      setResult(Constants.RESULT_TRANSFERRED);
      finish();
    }
 else {
      startPlay();
    }
  }
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == Constants.REQUEST_CODE_PATCH_CAMERA) {
    if (resultCode == Constants.RESULT_TRUE) {
      startPlay();
    }
 else     if (resultCode == Constants.RESULT_FALSE) {
      startPlay();
    }
  }
 else {
    if (resultCode == Constants.RESULT_DELETED) {
      setResult(Constants.RESULT_TRUE);
      finish();
    }
 else     if (resultCode == Constants.RESULT_TRANSFERRED) {
      setResult(Constants.RESULT_TRANSFERRED);
      finish();
    }
 else     if (resultCode == Constants.RESULT_ACCESS_REMOVED) {
      setResult(Constants.RESULT_ACCESS_REMOVED);
      finish();
    }
 else {
      startPlay();
    }
  }
}
Program: 34052
Project: 34052
Buggy source:
public void testGetLatestFileName(){
  assertEquals("String_Node_Str",SnapshotManager.getLatestFileName(ALL_FILES_ARRAY));
}

Fixed version (ground truth):
public void testGetLatestFileName(){
}
Program: 34053
Project: 34053
Buggy source:
public boolean isScanning(){
  if (cancelMenuItem.isVisible()) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean isScanning(){
  return cancelMenuItem != null && cancelMenuItem.isVisible();
}
Program: 34055
Project: 34055
Buggy source:
private void fillDiscoveredCameraDetails(DiscoveredCamera camera){
  if (camera != null) {
    if (camera.hasExternalIp()) {
      externalHostEdit.setText(camera.getExternalIp());
    }
    if (camera.hasExternalHttp()) {
      externalHttpEdit.setText(String.valueOf(camera.getExthttp()));
    }
    if (camera.hasExternalRtsp()) {
      externalRtspEdit.setText(String.valueOf(camera.getExtrtsp()));
    }
    if (camera.hasName()) {
      cameraNameEdit.setText(camera.getName());
    }
 else {
      cameraNameEdit.setText((camera.getVendor() + "String_Node_Str" + camera.getModel()).toUpperCase());
    }
  }
}

Fixed version (ground truth):
private void fillDiscoveredCameraDetails(DiscoveredCamera camera){
  if (camera != null) {
    Log.d(TAG,camera.toString());
    if (camera.hasExternalIp()) {
      externalHostEdit.setText(camera.getExternalIp());
    }
    if (camera.hasExternalHttp()) {
      externalHttpEdit.setText(String.valueOf(camera.getExthttp()));
    }
    if (camera.hasExternalRtsp()) {
      externalRtspEdit.setText(String.valueOf(camera.getExtrtsp()));
    }
    if (camera.hasName()) {
      String cameraName=camera.getName();
      if (cameraName.length() > 24) {
        cameraName=cameraName.substring(0,23);
      }
      cameraNameEdit.setText(cameraName);
    }
 else {
      cameraNameEdit.setText((camera.getVendor() + "String_Node_Str" + camera.getModel()).toUpperCase());
    }
  }
}
Program: 34056
Project: 34056
Buggy source:
private void fillDefaults(Model model){
  try {
    Defaults defaults=model.getDefaults();
    Auth basicAuth=defaults.getAuth(Auth.TYPE_BASIC);
    if (basicAuth != null) {
      usernameEdit.setText(basicAuth.getUsername());
      passwordEdit.setText(basicAuth.getPassword());
    }
    jpgUrlEdit.setText(defaults.getJpgURL());
    if (!model.getName().equals(Model.DEFAULT_MODEL_NAME)) {
      jpgUrlEdit.setFocusable(false);
      jpgUrlEdit.setClickable(true);
    }
 else {
      jpgUrlEdit.setFocusable(true);
      jpgUrlEdit.setClickable(true);
    }
  }
 catch (  EvercamException e) {
    Log.e(TAG,"String_Node_Str" + e.toString());
  }
}

Fixed version (ground truth):
private void fillDefaults(Model model){
  try {
    Defaults defaults=model.getDefaults();
    Auth basicAuth=defaults.getAuth(Auth.TYPE_BASIC);
    if (basicAuth != null) {
      usernameEdit.setText(basicAuth.getUsername());
      passwordEdit.setText(basicAuth.getPassword());
    }
    jpgUrlEdit.setText(defaults.getJpgURL());
    if (!model.getName().equals(Model.DEFAULT_MODEL_NAME) && !jpgUrlEdit.getText().toString().isEmpty()) {
      jpgUrlEdit.setFocusable(false);
      jpgUrlEdit.setClickable(true);
    }
 else {
      jpgUrlEdit.setFocusable(true);
      jpgUrlEdit.setClickable(true);
      jpgUrlEdit.setFocusableInTouchMode(true);
    }
  }
 catch (  EvercamException e) {
    Log.e(TAG,"String_Node_Str" + e.toString());
  }
}
Program: 34057
Project: 34057
Buggy source:
private void clearDefaults(){
  usernameEdit.setText("String_Node_Str");
  passwordEdit.setText("String_Node_Str");
  jpgUrlEdit.setText("String_Node_Str");
}

Fixed version (ground truth):
private void clearDefaults(){
  usernameEdit.setText("String_Node_Str");
  passwordEdit.setText("String_Node_Str");
  jpgUrlEdit.setText("String_Node_Str");
  jpgUrlEdit.setFocusable(true);
  jpgUrlEdit.setClickable(true);
  jpgUrlEdit.setFocusableInTouchMode(true);
}
Program: 34058
Project: 34058
Buggy source:
public void onScanningFinished(){
  updateScanPercentage(null);
  showTextProgress(false);
  showHorizontalProgress(false);
}

Fixed version (ground truth):
public void onScanningFinished(){
  updateScanPercentage(null);
  showTextProgress(false);
  showHorizontalProgress(false);
  showCancelButton(false);
}
Program: 34059
Project: 34059
Buggy source:
public void onScanningStarted(){
  showHorizontalProgress(true);
  showTextProgress(true);
}

Fixed version (ground truth):
public void onScanningStarted(){
  showHorizontalProgress(true);
  showTextProgress(true);
  showCancelButton(true);
}
Program: 34060
Project: 34060
Buggy source:
@Override public void onActiveIp(String ip){
  if (!pool.isShutdown()) {
    pool.execute(new IpScanRunnable(ip));
  }
}

Fixed version (ground truth):
@Override public void onActiveIp(String ip){
  if (!pool.isShutdown() && !isCancelled()) {
    pool.execute(new IpScanRunnable(ip));
  }
}
Program: 34061
Project: 34061
Buggy source:
@Override public void run(){
  try {
    GatewayDevice gatewayDevice=new GatewayDevice(routerIp);
    ArrayList<NatMapEntry> mapEntries=gatewayDevice.getNatTableArray();
    if (mapEntries.size() > 0) {
      for (      NatMapEntry mapEntry : mapEntries) {
        String natIp=mapEntry.getIpAddress();
        for (        DiscoveredCamera discoveredCamera : cameraList) {
          if (discoveredCamera.getIP().equals(natIp)) {
            int natInternalPort=mapEntry.getInternalPort();
            int natExternalPort=mapEntry.getExternalPort();
            DiscoveredCamera publishCamera=new DiscoveredCamera(natIp);
            if (discoveredCamera.getHttp() == natInternalPort) {
              publishCamera.setExthttp(natExternalPort);
            }
            if (discoveredCamera.getRtsp() == natInternalPort) {
              publishCamera.setExtrtsp(natExternalPort);
            }
            publishProgress(publishCamera);
            break;
          }
        }
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  natDone=true;
  scanPercentage+=PER__DISCOVERY_METHOD_PERCENT;
  getScanActivity().updateScanPercentage(scanPercentage);
}

Fixed version (ground truth):
@Override public void run(){
  try {
    GatewayDevice gatewayDevice=new GatewayDevice(routerIp);
    ArrayList<NatMapEntry> mapEntries=gatewayDevice.getNatTableArray();
    if (mapEntries.size() > 0) {
      for (      NatMapEntry mapEntry : mapEntries) {
        String natIp=mapEntry.getIpAddress();
        for (        DiscoveredCamera discoveredCamera : cameraList) {
          if (discoveredCamera.getIP().equals(natIp)) {
            int natInternalPort=mapEntry.getInternalPort();
            int natExternalPort=mapEntry.getExternalPort();
            DiscoveredCamera publishCamera=new DiscoveredCamera(natIp);
            if (discoveredCamera.getHttp() == natInternalPort) {
              publishCamera.setExthttp(natExternalPort);
            }
            if (discoveredCamera.getRtsp() == natInternalPort) {
              publishCamera.setExtrtsp(natExternalPort);
            }
            publishProgress(publishCamera);
            break;
          }
        }
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  natDone=true;
  scanPercentage+=PER__DISCOVERY_METHOD_PERCENT;
  updatePercentageOnActivity(scanPercentage);
}
Program: 34062
Project: 34062
Buggy source:
@Override protected void onProgressUpdate(DiscoveredCamera... discoveredCameras){
  getScanActivity().addNewCameraToResultList(discoveredCameras[0]);
}

Fixed version (ground truth):
@Override protected void onProgressUpdate(DiscoveredCamera... discoveredCameras){
  if (getScanActivity() != null) {
    getScanActivity().addNewCameraToResultList(discoveredCameras[0]);
  }
}
Program: 34063
Project: 34063
Buggy source:
@Override public void onIpScanned(String ip){
  scanPercentage+=getPerDevicePercent();
  getScanActivity().updateScanPercentage(scanPercentage);
}

Fixed version (ground truth):
@Override public void onIpScanned(String ip){
  scanPercentage+=getPerDevicePercent();
  updatePercentageOnActivity(scanPercentage);
}
Program: 34064
Project: 34064
Buggy source:
public ScanForCameraTask(ScanActivity scanActivity){
  this.scanActivityReference=new WeakReference<>(scanActivity);
  netInfo=new NetInfo(scanActivity);
  pool=Executors.newFixedThreadPool(EvercamDiscover.DEFAULT_FIXED_POOL);
  cameraList=new ArrayList<>();
}

Fixed version (ground truth):
public ScanForCameraTask(ScanActivity scanActivity){
  this.scanActivityReference=new WeakReference<>(scanActivity);
  netInfo=new NetInfo(scanActivity);
  pool=Executors.newFixedThreadPool(EvercamDiscover.DEFAULT_FIXED_POOL);
  cameraList=new ArrayList<>();
  upnpDeviceList=new ArrayList<>();
}
Program: 34065
Project: 34065
Buggy source:
@Override protected ArrayList<DiscoveredCamera> doInBackground(Void... params){
  startTime=new Date();
  try {
    ScanRange scanRange=new ScanRange(netInfo.getGatewayIp(),netInfo.getNetmaskIp());
    totalDevices=scanRange.size();
    externalIp=NetworkInfo.getExternalIP();
    if (!pool.isShutdown()) {
      pool.execute(new OnvifRunnable());
      pool.execute(new UpnpRunnable());
      pool.execute(new NatRunnable(netInfo.getGatewayIp()));
    }
    IpScan ipScan=new IpScan(new ScanResult(){
      @Override public void onActiveIp(      String ip){
        if (!pool.isShutdown()) {
          pool.execute(new IpScanRunnable(ip));
        }
      }
      @Override public void onIpScanned(      String ip){
        scanPercentage+=getPerDevicePercent();
        getScanActivity().updateScanPercentage(scanPercentage);
      }
    }
);
    ipScan.scanAll(scanRange);
  }
 catch (  Exception e) {
    Log.e(TAG,e.getLocalizedMessage());
    e.printStackTrace();
  }
  int loopCount=0;
  while (!onvifDone && !upnpDone || !natDone || singleIpStartedCount != singleIpEndedCount) {
    loopCount++;
    if (loopCount > 20)     break;
    if (isCancelled())     break;
    try {
      Thread.sleep(500);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
  return cameraList;
}

Fixed version (ground truth):
@Override protected ArrayList<DiscoveredCamera> doInBackground(Void... params){
  startTime=new Date();
  try {
    final ScanRange scanRange=new ScanRange(netInfo.getGatewayIp(),netInfo.getNetmaskIp());
    totalDevices=scanRange.size();
    externalIp=NetworkInfo.getExternalIP();
    if (!pool.isShutdown() && !isCancelled()) {
      pool.execute(new OnvifRunnable());
      pool.execute(new UpnpRunnable());
      pool.execute(new NatRunnable(netInfo.getGatewayIp()));
    }
    IpScan ipScan=new IpScan(new ScanResult(){
      @Override public void onActiveIp(      String ip){
        if (!pool.isShutdown() && !isCancelled()) {
          pool.execute(new IpScanRunnable(ip));
        }
      }
      @Override public void onIpScanned(      String ip){
        scanPercentage+=getPerDevicePercent();
        updatePercentageOnActivity(scanPercentage);
      }
    }
);
    ipScan.scanAll(scanRange);
  }
 catch (  Exception e) {
    Log.e(TAG,e.getLocalizedMessage());
    e.printStackTrace();
  }
  int loopCount=0;
  while (!onvifDone && !upnpDone || !natDone || singleIpStartedCount != singleIpEndedCount) {
    loopCount++;
    if (loopCount > 20)     break;
    if (isCancelled())     break;
    try {
      Thread.sleep(500);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
  return cameraList;
}
Program: 34066
Project: 34066
Buggy source:
@Override protected void onPostExecute(ArrayList<DiscoveredCamera> cameraList){
  getScanActivity().showScanResults(cameraList);
  getScanActivity().onScanningFinished();
  pool.shutdown();
  Float scanningTime=Commons.calculateTimeDifferenceFrom(startTime);
  Log.d(TAG,"String_Node_Str" + scanningTime);
  String username="String_Node_Str";
  if (AppData.defaultUser != null) {
    username=AppData.defaultUser.getUsername();
  }
  new ScanFeedbackItem(getScanActivity(),username,scanningTime,cameraList).sendToKeenIo();
}

Fixed version (ground truth):
@Override protected void onPostExecute(ArrayList<DiscoveredCamera> cameraList){
  if (getScanActivity() != null) {
    getScanActivity().showScanResults(cameraList);
    getScanActivity().onScanningFinished();
  }
  pool.shutdown();
  Float scanningTime=Commons.calculateTimeDifferenceFrom(startTime);
  Log.d(TAG,"String_Node_Str" + scanningTime);
  String username="String_Node_Str";
  if (AppData.defaultUser != null) {
    username=AppData.defaultUser.getUsername();
  }
  new ScanFeedbackItem(getScanActivity(),username,scanningTime,cameraList).sendToKeenIo();
}
Program: 34067
Project: 34067
Buggy source:
@Override public void onUpnpDeviceFound(UpnpDevice upnpDevice){
  String ipFromUpnp=upnpDevice.getIp();
  if (ipFromUpnp != null && !ipFromUpnp.isEmpty()) {
    for (    DiscoveredCamera discoveredCamera : cameraList) {
      if (discoveredCamera.getIP().equals(upnpDevice.getIp())) {
        DiscoveredCamera publishCamera=new DiscoveredCamera(discoveredCamera.getIP());
        int port=upnpDevice.getPort();
        String model=upnpDevice.getModel();
        if (port != 0) {
          publishCamera.setHttp(port);
        }
        publishCamera.setModel(model);
        publishProgress(publishCamera);
        break;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onUpnpDeviceFound(UpnpDevice upnpDevice){
  Log.d(TAG,"String_Node_Str" + upnpDevice.toString());
  upnpDeviceList.add(upnpDevice);
  String ipFromUpnp=upnpDevice.getIp();
  if (ipFromUpnp != null && !ipFromUpnp.isEmpty()) {
    for (    DiscoveredCamera discoveredCamera : cameraList) {
      if (discoveredCamera.getIP().equals(upnpDevice.getIp())) {
        DiscoveredCamera publishCamera=new DiscoveredCamera(discoveredCamera.getIP());
        mergeUpnpDeviceToCamera(upnpDevice,publishCamera);
        publishProgress(publishCamera);
        break;
      }
    }
  }
}
Program: 34068
Project: 34068
Buggy source:
private void play(EvercamCamera camera){
  nativeSetUsername(camera.getUsername());
  nativeSetPassword(camera.getPassword());
  nativePlay();
}

Fixed version (ground truth):
private void play(EvercamCamera camera){
  nativePlay();
}
Program: 34069
Project: 34069
Buggy source:
/** 
 * * Player 
 */
private void createPlayer(EvercamCamera camera){
  startTime=new Date();
  if (evercamCamera.hasRtspUrl()) {
    nativeSetUri(camera.getExternalRtspUrl());
    play(camera);
    surfaceView.setVisibility(View.VISIBLE);
    imageView.setVisibility(View.GONE);
    hideProgressView();
  }
 else {
    showImagesVideo=true;
    createBrowseJpgTask();
  }
}

Fixed version (ground truth):
private void createPlayer(EvercamCamera camera){
  startTime=new Date();
  if (evercamCamera.hasRtspUrl()) {
    Log.e(TAG,"String_Node_Str" + createUri(camera));
    nativeSetUri(createUri(camera));
    play(camera);
    surfaceView.setVisibility(View.VISIBLE);
    imageView.setVisibility(View.GONE);
    hideProgressView();
  }
 else {
    showImagesVideo=true;
    createBrowseJpgTask();
  }
}
Program: 34071
Project: 34071
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  try {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    initAnalyticsObjects();
    readShortcutCameraId();
    if (!liveViewCameraId.isEmpty()) {
      startingCameraID=liveViewCameraId;
      liveViewCameraId="String_Node_Str";
    }
    launchSleepTimer();
    setDisplayOriention();
    if (this.getActionBar() != null) {
      this.getActionBar().setDisplayHomeAsUpEnabled(true);
    }
    try {
      GStreamer.init(this);
    }
 catch (    Exception e) {
      Log.e(TAG,e.getLocalizedMessage());
      EvercamPlayApplication.sendCaughtException(this,e);
      finish();
      return;
    }
    nativeInit();
    nativeSetTcpTimeout(TCP_TIMEOUT);
    setContentView(R.layout.video_activity_layout);
    initialPageElements();
    checkIsShortcutCameraExists();
    startPlay();
  }
 catch (  OutOfMemoryError e) {
    Log.e(TAG,e.toString() + "String_Node_Str" + Log.getStackTraceString(e));
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  try {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    initAnalyticsObjects();
    readShortcutCameraId();
    if (!liveViewCameraId.isEmpty()) {
      startingCameraID=liveViewCameraId;
      liveViewCameraId="String_Node_Str";
    }
    launchSleepTimer();
    setDisplayOriention();
    if (this.getActionBar() != null) {
      this.getActionBar().setDisplayHomeAsUpEnabled(true);
    }
    try {
      GStreamer.init(this);
    }
 catch (    Exception e) {
      Log.e(TAG,e.getLocalizedMessage());
      EvercamPlayApplication.sendCaughtException(this,e);
      finish();
      return;
    }
    nativeInit();
    setContentView(R.layout.video_activity_layout);
    initialPageElements();
    checkIsShortcutCameraExists();
    startPlay();
  }
 catch (  OutOfMemoryError e) {
    Log.e(TAG,e.toString() + "String_Node_Str" + Log.getStackTraceString(e));
  }
}
Program: 34072
Project: 34072
Buggy source:
@Override protected void onDestroy(){
  Log.d(TAG,"String_Node_Str");
  super.onDestroy();
  nativeStop();
  nativeFinalize();
  nativeSurfaceFinalize();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  nativeFinalize();
  super.onDestroy();
}
Program: 34073
Project: 34073
Buggy source:
private native void nativeRequestSample();

Fixed version (ground truth):
private native void nativeRequestSample(String fileName);
Program: 34074
Project: 34074
Buggy source:
private void setMessage(final String message){
}

Fixed version (ground truth):
private void setMessage(final String message){
  Log.d(TAG,"String_Node_Str" + message);
}
Program: 34075
Project: 34075
Buggy source:
private void onVideoLoaded(){
  Log.d(TAG,"String_Node_Str");
  isPlayingJpg=false;
  startTimeCounter();
}

Fixed version (ground truth):
private void onVideoLoaded(){
  runOnUiThread(new Runnable(){
    public void run(){
      Log.d(TAG,"String_Node_Str");
      isPlayingJpg=false;
      startTimeCounter();
    }
  }
);
}
Program: 34076
Project: 34076
Buggy source:
/** 
 * Calculate how long it takes for the user to see the camera list
 */
public void calculateLoadingTimeAndSend(){
  if (startTime != null) {
    float timeDifferenceFloat=Commons.calculateTimeDifferenceFrom(startTime);
    Log.d(TAG,"String_Node_Str" + databaseLoadTime + "String_Node_Str"+ timeDifferenceFloat+ "String_Node_Str"+ "String_Node_Str");
    startTime=null;
    LoadTimeFeedbackItem feedbackItem=new LoadTimeFeedbackItem(this,AppData.defaultUser.getUsername(),databaseLoadTime,timeDifferenceFloat);
    databaseLoadTime=0;
    logger.info(feedbackItem.toJson());
    feedbackItem.sendToKeenIo(client);
  }
}

Fixed version (ground truth):
/** 
 * Calculate how long it takes for the user to see the camera list
 */
public void calculateLoadingTimeAndSend(){
  if (startTime != null) {
    float timeDifferenceFloat=Commons.calculateTimeDifferenceFrom(startTime);
    Log.d(TAG,"String_Node_Str" + databaseLoadTime + "String_Node_Str"+ timeDifferenceFloat+ "String_Node_Str"+ "String_Node_Str");
    startTime=null;
    String username="String_Node_Str";
    if (AppData.defaultUser != null) {
      username=AppData.defaultUser.getUsername();
    }
    LoadTimeFeedbackItem feedbackItem=new LoadTimeFeedbackItem(this,username,databaseLoadTime,timeDifferenceFloat);
    databaseLoadTime=0;
    logger.info(feedbackItem.toJson());
    feedbackItem.sendToKeenIo(client);
  }
}
Program: 34077
Project: 34077
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  customProgressDialog=new CustomProgressDialog(this);
  getWindow().requestFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.login);
  setUnderLine();
  Button btnLogin=(Button)findViewById(R.id.btnLogin);
  usernameEdit=(EditText)findViewById(R.id.editUsername);
  passwordEdit=(EditText)findViewById(R.id.editPassword);
  btnLogin.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      new LoginCheckInternetTask(LoginActivity.this,InternetCheckType.LOGIN).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
  }
);
  signUpLink.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      new LoginCheckInternetTask(LoginActivity.this,InternetCheckType.SIGNUP).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
  }
);
  hideLogoIfNecessary();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  customProgressDialog=new CustomProgressDialog(this);
  getWindow().requestFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.login);
  Button btnLogin=(Button)findViewById(R.id.btnLogin);
  TextView signUpLink=(TextView)findViewById(R.id.signupLink);
  usernameEdit=(EditText)findViewById(R.id.editUsername);
  passwordEdit=(EditText)findViewById(R.id.editPassword);
  btnLogin.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      new LoginCheckInternetTask(LoginActivity.this,InternetCheckType.LOGIN).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
  }
);
  signUpLink.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      new LoginCheckInternetTask(LoginActivity.this,InternetCheckType.SIGNUP).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
  }
);
  hideLogoIfNecessary();
}
Program: 34078
Project: 34078
Buggy source:
public void attemptLogin(){
  if (loginTask != null) {
    return;
  }
  usernameEdit.setError(null);
  passwordEdit.setError(null);
  username=usernameEdit.getText().toString();
  password=passwordEdit.getText().toString();
  boolean cancel=false;
  View focusView=null;
  if (TextUtils.isEmpty(username)) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_username_required);
    focusView=usernameEdit;
    cancel=true;
  }
 else   if (username.contains("String_Node_Str")) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_invalid_username);
    focusView=usernameEdit;
    cancel=true;
  }
 else   if (TextUtils.isEmpty(password)) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_password_required);
    focusView=passwordEdit;
    cancel=true;
  }
 else   if (password.contains("String_Node_Str")) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_invalid_password);
    focusView=passwordEdit;
    cancel=true;
  }
  if (cancel) {
    focusView.requestFocus();
  }
 else {
    customProgressDialog.show(getString(R.string.login_progress_signing_in));
    InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    if (getCurrentFocus() != null) {
      inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),0);
    }
    loginTask=new LoginTask();
    loginTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
}

Fixed version (ground truth):
public void attemptLogin(){
  if (loginTask != null) {
    return;
  }
  usernameEdit.setError(null);
  passwordEdit.setError(null);
  username=usernameEdit.getText().toString();
  password=passwordEdit.getText().toString();
  boolean cancel=false;
  View focusView=null;
  if (TextUtils.isEmpty(username)) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_username_required);
    focusView=usernameEdit;
    cancel=true;
  }
 else   if (!username.matches(Constants.REGULAR_EXPRESSION_USERNAME)) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_invalid_username);
    focusView=usernameEdit;
    cancel=true;
  }
 else   if (TextUtils.isEmpty(password)) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_password_required);
    focusView=passwordEdit;
    cancel=true;
  }
 else   if (password.contains("String_Node_Str")) {
    CustomToast.showInCenter(getApplicationContext(),R.string.error_invalid_password);
    focusView=passwordEdit;
    cancel=true;
  }
  if (cancel) {
    focusView.requestFocus();
  }
 else {
    customProgressDialog.show(getString(R.string.login_progress_signing_in));
    InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    if (getCurrentFocus() != null) {
      inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),0);
    }
    loginTask=new LoginTask();
    loginTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
}
Program: 34079
Project: 34079
Buggy source:
private void readShortcutCameraId(){
  Intent liveViewIntent=this.getIntent();
  if (liveViewIntent != null && liveViewIntent.getExtras() != null) {
    EvercamPlayApplication.sendEventAnalytics(this,R.string.category_shortcut,R.string.action_shortcut_use,R.string.label_shortcut_use);
    try {
      getMixpanel().sendEvent(R.string.mixpanel_event_use_shortcut,new JSONObject().put("String_Node_Str",evercamCamera.getCameraId()));
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
    liveViewCameraId=liveViewIntent.getExtras().getString(HomeShortcut.KEY_CAMERA_ID,"String_Node_Str");
  }
}

Fixed version (ground truth):
private void readShortcutCameraId(){
  Intent liveViewIntent=this.getIntent();
  if (liveViewIntent != null && liveViewIntent.getExtras() != null) {
    EvercamPlayApplication.sendEventAnalytics(this,R.string.category_shortcut,R.string.action_shortcut_use,R.string.label_shortcut_use);
    try {
      if (evercamCamera != null) {
        getMixpanel().sendEvent(R.string.mixpanel_event_use_shortcut,new JSONObject().put("String_Node_Str",evercamCamera.getCameraId()));
      }
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
    liveViewCameraId=liveViewIntent.getExtras().getString(HomeShortcut.KEY_CAMERA_ID,"String_Node_Str");
  }
}
Program: 34080
Project: 34080
Buggy source:
private static Bitmap getIconForShortcut(EvercamCamera evercamCamera,Context context){
  Bitmap bitmap=null;
  try {
    bitmap=getThumbnailFor(context,evercamCamera);
    if (bitmap == null) {
      bitmap=BitmapFactory.decodeResource(context.getResources(),R.drawable.icon_evercam);
      return Bitmap.createScaledBitmap(bitmap,192,192,false);
    }
    bitmap=Bitmap.createScaledBitmap(bitmap,192,192,false);
    bitmap=getRoundedCornerBitmap(bitmap);
    bitmap=addBorder(bitmap,3,3,3,3,Color.GRAY);
    bitmap=getRoundedCornerBitmap(bitmap);
    bitmap=addBorder(bitmap,0,30,20,30,Color.TRANSPARENT);
    Bitmap logoBitmap=BitmapFactory.decodeResource(context.getResources(),R.drawable.icon_40x40);
    appendOverlay(bitmap,logoBitmap);
  }
 catch (  EvercamException e) {
    Log.e(TAG,e.getMessage());
  }
  return bitmap;
}

Fixed version (ground truth):
private static Bitmap getIconForShortcut(EvercamCamera evercamCamera,Context context){
  Bitmap bitmap=null;
  try {
    bitmap=getThumbnailFor(context,evercamCamera);
    if (bitmap == null) {
      bitmap=BitmapFactory.decodeResource(context.getResources(),R.drawable.icon_evercam);
      return Bitmap.createScaledBitmap(bitmap,192,192,false);
    }
    bitmap=Bitmap.createScaledBitmap(bitmap,192,192,false);
    bitmap=getRoundedCornerBitmap(bitmap);
    bitmap=addBorder(bitmap,3,3,3,3,Color.GRAY);
    bitmap=getRoundedCornerBitmap(bitmap);
    bitmap=addBorder(bitmap,0,30,20,30,Color.TRANSPARENT);
    Bitmap logoBitmap=BitmapFactory.decodeResource(context.getResources(),R.drawable.icon_50x50);
    logoBitmap=Bitmap.createScaledBitmap(logoBitmap,80,80,false);
    appendOverlay(bitmap,logoBitmap);
  }
 catch (  EvercamException e) {
    Log.e(TAG,e.getMessage());
  }
  return bitmap;
}
Program: 34081
Project: 34081
Buggy source:
private static Bitmap getThumbnailFor(Context context,EvercamCamera evercamCamera) throws EvercamException {
  if (evercamCamera.camera != null) {
    byte[] snapshotByte=evercamCamera.camera.getThumbnailData();
    return BitmapFactory.decodeByteArray(snapshotByte,0,snapshotByte.length);
  }
 else {
    return EvercamFile.loadBitmapForCamera(context,evercamCamera.getCameraId());
  }
}

Fixed version (ground truth):
private static Bitmap getThumbnailFor(Context context,EvercamCamera evercamCamera) throws EvercamException {
  return EvercamFile.loadBitmapForCamera(context,evercamCamera.getCameraId());
}
Program: 34082
Project: 34082
Buggy source:
private void setScrollStopListenerFor(final CustomScrollView scrollView){
  scrollView.setOnTouchListener(new OnTouchListener(){
    @Override public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_UP) {
        scrollView.startScrollerTask();
      }
      return false;
    }
  }
);
  scrollView.setOnScrollStoppedListener(new OnScrollStoppedListener(){
    @Override public void onScrollStopped(){
      Log.d(TAG,"String_Node_Str");
      onScreenScrolled();
    }
  }
);
}

Fixed version (ground truth):
private void setScrollStopListenerFor(final CustomScrollView scrollView){
  scrollView.setOnTouchListener(new OnTouchListener(){
    @Override public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_UP) {
        scrollView.startScrollerTask();
      }
      return false;
    }
  }
);
  scrollView.setOnScrollStoppedListener(new OnScrollStoppedListener(){
    @Override public void onScrollStopped(){
      onScreenScrolled();
    }
  }
);
}
Program: 34083
Project: 34083
Buggy source:
@Override public void onScrollStopped(){
  Log.d(TAG,"String_Node_Str");
  onScreenScrolled();
}

Fixed version (ground truth):
@Override public void onScrollStopped(){
  onScreenScrolled();
}
Program: 34084
Project: 34084
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (Constants.isAppTrackingEnabled) {
    BugSenseHandler.initAndStartSession(this,Constants.bugsense_ApiKey);
  }
  setContentView(R.layout.activity_recording_web);
  Bundle bundle=getIntent().getExtras();
  String cameraId=bundle.getString(Constants.BUNDLE_KEY_CAMERA_ID);
  progressDialog=new CustomProgressDialog(this);
  RecordingWebView webView=(RecordingWebView)findViewById(R.id.recordings_webview);
  webView.loadRecordingWidget(cameraId);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (Constants.isAppTrackingEnabled) {
    BugSenseHandler.initAndStartSession(this,Constants.bugsense_ApiKey);
  }
  setContentView(R.layout.activity_recording_web);
  Bundle bundle=getIntent().getExtras();
  if (bundle != null) {
    String cameraId=bundle.getString(Constants.BUNDLE_KEY_CAMERA_ID);
    progressDialog=new CustomProgressDialog(this);
    RecordingWebView webView=(RecordingWebView)findViewById(R.id.recordings_webview);
    webView.loadRecordingWidget(cameraId);
  }
 else {
    finish();
  }
}
Program: 34086
Project: 34086
Buggy source:
private EvercamCamera getCameraFromCursor(Cursor cursor,EvercamCamera evercamCamera){
  evercamCamera.setId(Integer.parseInt(cursor.getString(0)));
  evercamCamera.setCameraId(cursor.getString(1));
  evercamCamera.setName(cursor.getString(2));
  evercamCamera.setOwner(cursor.getString(3));
  evercamCamera.setUsername(cursor.getString(4));
  evercamCamera.setPassword(cursor.getString(5));
  evercamCamera.setTimezone(cursor.getString(6));
  evercamCamera.setVendor(cursor.getString(7));
  evercamCamera.setModel(cursor.getString(8));
  evercamCamera.setMac(cursor.getString(9));
  evercamCamera.setExternalSnapshotUrl(cursor.getString(10));
  evercamCamera.setInternalSnapshotUrl(cursor.getString(11));
  evercamCamera.setExternalRtspUrl(cursor.getString(12));
  evercamCamera.setInternalRtspUrl(cursor.getString(13));
  evercamCamera.setStatus(cursor.getString(14));
  evercamCamera.setHasCredentials(cursor.getInt(15) == 1);
  evercamCamera.setInternalHost(cursor.getString(16));
  evercamCamera.setExternalHost(cursor.getString(17));
  evercamCamera.setInternalHttp(cursor.getInt(18));
  evercamCamera.setExternalHttp(cursor.getInt(19));
  evercamCamera.setInternalRtsp(cursor.getInt(20));
  evercamCamera.setExternalRtsp(cursor.getInt(21));
  evercamCamera.setRealOwner(cursor.getString(22));
  evercamCamera.setCanEdit(cursor.getInt(23) == 1);
  evercamCamera.setCanDelete(cursor.getInt(24) == 1);
  return evercamCamera;
}

Fixed version (ground truth):
private EvercamCamera getCameraFromCursor(Cursor cursor,EvercamCamera evercamCamera){
  evercamCamera.setId(Integer.parseInt(cursor.getString(0)));
  evercamCamera.setCameraId(cursor.getString(1));
  evercamCamera.setName(cursor.getString(2));
  evercamCamera.setOwner(cursor.getString(3));
  evercamCamera.setUsername(cursor.getString(4));
  evercamCamera.setPassword(cursor.getString(5));
  evercamCamera.setTimezone(cursor.getString(6));
  evercamCamera.setVendor(cursor.getString(7));
  evercamCamera.setModel(cursor.getString(8));
  evercamCamera.setMac(cursor.getString(9));
  evercamCamera.setExternalSnapshotUrl(cursor.getString(10));
  evercamCamera.setInternalSnapshotUrl(cursor.getString(11));
  evercamCamera.setExternalRtspUrl(cursor.getString(12));
  evercamCamera.setInternalRtspUrl(cursor.getString(13));
  evercamCamera.setStatus(cursor.getString(14));
  evercamCamera.setHasCredentials(cursor.getInt(15) == 1);
  evercamCamera.setInternalHost(cursor.getString(16));
  evercamCamera.setExternalHost(cursor.getString(17));
  evercamCamera.setInternalHttp(cursor.getInt(18));
  evercamCamera.setExternalHttp(cursor.getInt(19));
  evercamCamera.setInternalRtsp(cursor.getInt(20));
  evercamCamera.setExternalRtsp(cursor.getInt(21));
  evercamCamera.setThumbnailUrl(cursor.getString(22));
  evercamCamera.setRealOwner(cursor.getString(23));
  evercamCamera.setCanEdit(cursor.getInt(24) == 1);
  evercamCamera.setCanDelete(cursor.getInt(25) == 1);
  return evercamCamera;
}
Program: 34089
Project: 34089
Buggy source:
public EvercamCamera getCamera(int id){
  EvercamCamera evercamCamera=null;
  SQLiteDatabase db=this.getReadableDatabase();
  Cursor cursor=db.query(TABLE_CAMERA,new String[]{KEY_ID,KEY_CAMERA_ID,KEY_CAMERA_NAME,KEY_OWNER,KEY_USERNAME,KEY_PASSWORD,KEY_TIMEZONE,KEY_VENDOR,KEY_MODEL,KEY_MAC,KEY_EXTERNAL_JPG_URL,KEY_INTERNAL_JPG_URL,KEY_EXTERNAL_RTSP_URL,KEY_INTERNAL_RTSP_URL,KEY_STATUS,KEY_HAS_CREDENTIAL,KEY_INTERNAL_HOST,KEY_EXTERNAL_HOST,KEY_INTERNAL_HTTP,KEY_EXTERNAL_HTTP,KEY_INTERNAL_RTSP,KEY_EXTERNAL_RTSP,KEY_REAL_OWNER,KEY_CAN_EDIT,KEY_CAN_DELETE},KEY_ID + "String_Node_Str",new String[]{String.valueOf(id)},null,null,null,null);
  if (cursor != null) {
    if (cursor.moveToFirst()) {
      evercamCamera=new EvercamCamera();
      evercamCamera=getCameraFromCursor(cursor,evercamCamera);
    }
    cursor.close();
  }
  db.close();
  return evercamCamera;
}

Fixed version (ground truth):
public EvercamCamera getCamera(int id){
  EvercamCamera evercamCamera=null;
  SQLiteDatabase db=this.getReadableDatabase();
  Cursor cursor=db.query(TABLE_CAMERA,new String[]{KEY_ID,KEY_CAMERA_ID,KEY_CAMERA_NAME,KEY_OWNER,KEY_USERNAME,KEY_PASSWORD,KEY_TIMEZONE,KEY_VENDOR,KEY_MODEL,KEY_MAC,KEY_EXTERNAL_JPG_URL,KEY_INTERNAL_JPG_URL,KEY_EXTERNAL_RTSP_URL,KEY_INTERNAL_RTSP_URL,KEY_STATUS,KEY_HAS_CREDENTIAL,KEY_INTERNAL_HOST,KEY_EXTERNAL_HOST,KEY_INTERNAL_HTTP,KEY_EXTERNAL_HTTP,KEY_INTERNAL_RTSP,KEY_EXTERNAL_RTSP,KEY_THUMBNAIL_URL,KEY_REAL_OWNER,KEY_CAN_EDIT,KEY_CAN_DELETE},KEY_ID + "String_Node_Str",new String[]{String.valueOf(id)},null,null,null,null);
  if (cursor != null) {
    if (cursor.moveToFirst()) {
      evercamCamera=new EvercamCamera();
      evercamCamera=getCameraFromCursor(cursor,evercamCamera);
    }
    cursor.close();
  }
  db.close();
  return evercamCamera;
}
Program: 34090
Project: 34090
Buggy source:
@Override public void run(){
  try {
    if (end)     return;
    if (evercamCamera.loadingStatus == ImageLoadingStatus.not_started) {
      if (evercamCamera.isActive()) {
        showAndSaveLiveSnapshot();
      }
    }
 else     if (evercamCamera.loadingStatus == ImageLoadingStatus.live_received) {
      setLayoutForLiveImageReceived();
    }
 else     if (evercamCamera.loadingStatus == ImageLoadingStatus.live_not_received) {
      setLayoutForNoImageReceived();
    }
  }
 catch (  OutOfMemoryError e) {
    Log.e(TAG,e.toString() + "String_Node_Str" + Log.getStackTraceString(e));
    handler.postDelayed(LoadImageRunnable,5000);
    return;
  }
catch (  Exception e) {
    Log.e(TAG,e.toString() + "String_Node_Str" + Log.getStackTraceString(e));
    if (!end) {
      handler.postDelayed(LoadImageRunnable,5000);
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    if (end)     return;
    if (evercamCamera.loadingStatus == ImageLoadingStatus.not_started) {
      if (evercamCamera.isActive()) {
        showAndSaveLiveSnapshot();
      }
    }
 else     if (evercamCamera.loadingStatus == ImageLoadingStatus.live_received) {
      setLayoutForLiveImageReceived();
    }
 else     if (evercamCamera.loadingStatus == ImageLoadingStatus.live_not_received) {
      setLayoutForNoImageReceived();
    }
  }
 catch (  OutOfMemoryError e) {
    Log.e(TAG,e.toString() + "String_Node_Str" + Log.getStackTraceString(e));
    handler.postDelayed(LoadImageRunnable,5000);
  }
catch (  Exception e) {
    Log.e(TAG,e.toString() + "String_Node_Str" + Log.getStackTraceString(e));
    if (!end) {
      handler.postDelayed(LoadImageRunnable,5000);
    }
  }
}
Program: 34091
Project: 34091
Buggy source:
private void showAndSaveLiveSnapshot(){
  Target liveSnapshotTarget=new Target(){
    @Override public void onBitmapLoaded(    final Bitmap bitmap,    Picasso.LoadedFrom from){
      snapshotImageView.setImageBitmap(bitmap);
      CameraLayout.this.evercamCamera.loadingStatus=ImageLoadingStatus.live_received;
      handler.postDelayed(LoadImageRunnable,0);
      new Thread(new SaveImageRunnable(context,bitmap,evercamCamera.getCameraId())).start();
    }
    @Override public void onBitmapFailed(    Drawable errorDrawable){
      if (errorDrawable == null) {
        CameraLayout.this.evercamCamera.loadingStatus=ImageLoadingStatus.live_not_received;
        handler.postDelayed(LoadImageRunnable,0);
      }
    }
    @Override public void onPrepareLoad(    Drawable placeHolderDrawable){
    }
  }
;
  try {
    final String snapshotUrl=API.generateSnapshotUrlForCamera(evercamCamera.getCameraId());
    Picasso.with(context).load(snapshotUrl).into(liveSnapshotTarget);
  }
 catch (  EvercamException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void showAndSaveLiveSnapshot(){
  DownloadLiveSnapshotTask downloadLiveSnapshotTask=new DownloadLiveSnapshotTask(evercamCamera.getCameraId());
  downloadLiveSnapshotTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Program: 34092
Project: 34092
Buggy source:
public SaveImageRunnable(Context context,Bitmap bitmap,String cameraId){
  this.context=context;
  this.bitmap=bitmap;
  SaveImageRunnable.cameraId=cameraId;
}

Fixed version (ground truth):
public SaveImageRunnable(Context context,Bitmap bitmap,String cameraId){
  this.context=context;
  this.bitmap=bitmap;
  this.cameraId=cameraId;
}
Program: 34093
Project: 34093
Buggy source:
public static void saveImage(Context context,Bitmap bitmap,String cameraId){
  try {
    File externalFile=EvercamFile.getExternalFile(context,cameraId);
    createFile(externalFile,bitmap);
    checkFile(externalFile);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + Log.getStackTraceString(e));
  }
  try {
    File cacheFile=EvercamFile.getCacheFileRelative(context,cameraId);
    createFile(cacheFile,bitmap);
    checkFile(cacheFile);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + Log.getStackTraceString(e));
  }
}

Fixed version (ground truth):
public void saveImage(Context context,Bitmap bitmap,String cameraId){
  try {
    File externalFile=EvercamFile.getExternalFile(context,cameraId);
    createFile(externalFile,bitmap);
    checkFile(externalFile);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + Log.getStackTraceString(e));
  }
  try {
    File cacheFile=EvercamFile.getCacheFileRelative(context,cameraId);
    createFile(cacheFile,bitmap);
    checkFile(cacheFile);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + Log.getStackTraceString(e));
  }
}
Program: 34094
Project: 34094
Buggy source:
private static void checkFile(File file){
  if (file.exists()) {
    if (file.length() > 0) {
    }
 else {
      file.delete();
      Log.e(TAG,cameraId + "String_Node_Str");
    }
  }
 else {
    Log.e(TAG,"String_Node_Str" + cameraId);
  }
}

Fixed version (ground truth):
private void checkFile(File file){
  if (file.exists()) {
    if (file.length() > 0) {
    }
 else {
      file.delete();
      Log.e(TAG,cameraId + "String_Node_Str");
    }
  }
 else {
    Log.e(TAG,"String_Node_Str" + cameraId);
  }
}