Program: 109686
Project: 109686
Buggy source:
/** 
 * Downloads the main cert and the eip-service.json files given through the task parameter
 * @param task
 * @return true if eip-service.json was parsed as a JSON object correctly.
 */
private Bundle downloadJsonFiles(Bundle task){
  Bundle result=new Bundle();
  String cert_url=task.getString(Provider.CA_CERT);
  String eip_service_json_url=task.getString(EIP.KEY);
  boolean danger_on=task.getBoolean(ProviderItem.DANGER_ON);
  try {
    String cert_string=downloadWithCommercialCA(cert_url,danger_on);
    if (ConfigHelper.checkErroneousDownload(cert_string)) {
      JSONObject possible_errors=new JSONObject(cert_string);
      String reason_to_fail="String_Node_Str";
      if (cert_string.isEmpty())       reason_to_fail="String_Node_Str";
 else       reason_to_fail=possible_errors.getString(ERRORS);
      result.putString(ERRORS,reason_to_fail);
      result.putBoolean(RESULT_KEY,false);
    }
 else {
      X509Certificate certCert=ConfigHelper.parseX509CertificateFromString(cert_string);
      cert_string=Base64.encodeToString(certCert.getEncoded(),Base64.DEFAULT);
      ConfigHelper.saveSharedPref(Provider.CA_CERT,"String_Node_Str" + cert_string + "String_Node_Str");
    }
  }
 catch (  JSONException e) {
    e.printStackTrace();
    result.putBoolean(RESULT_KEY,false);
  }
catch (  CertificateException e) {
    e.printStackTrace();
    result.putBoolean(RESULT_KEY,false);
  }
  try {
    String eip_service_string=downloadWithCommercialCA(eip_service_json_url,danger_on);
    JSONObject eip_service_json=new JSONObject(eip_service_string);
    if (eip_service_json.has(ERRORS)) {
      String reason_to_fail=eip_service_json.getString(ERRORS);
      result.putString(ERRORS,reason_to_fail);
      result.putBoolean(RESULT_KEY,false);
    }
 else     ConfigHelper.saveSharedPref(EIP.KEY,eip_service_json);
    result.putBoolean(RESULT_KEY,true);
  }
 catch (  JSONException e) {
    result.putBoolean(RESULT_KEY,false);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Downloads the main cert and the eip-service.json files given through the task parameter
 * @param task
 * @return true if eip-service.json was parsed as a JSON object correctly.
 */
private Bundle downloadJsonFiles(Bundle task){
  Bundle result=new Bundle();
  String cert_url=task.getString(Provider.CA_CERT);
  String eip_service_json_url=task.getString(EIP.KEY);
  boolean danger_on=task.getBoolean(ProviderItem.DANGER_ON);
  try {
    String cert_string=downloadWithCommercialCA(cert_url,danger_on);
    if (ConfigHelper.checkErroneousDownload(cert_string)) {
      JSONObject possible_errors=new JSONObject(cert_string);
      String reason_to_fail="String_Node_Str";
      if (cert_string.isEmpty())       reason_to_fail="String_Node_Str";
 else       reason_to_fail=possible_errors.getString(ERRORS);
      result.putString(ERRORS,reason_to_fail);
      result.putBoolean(RESULT_KEY,false);
    }
 else {
      X509Certificate certCert=ConfigHelper.parseX509CertificateFromString(cert_string);
      cert_string=Base64.encodeToString(certCert.getEncoded(),Base64.DEFAULT);
      ConfigHelper.saveSharedPref(Provider.CA_CERT,"String_Node_Str" + cert_string + "String_Node_Str");
    }
  }
 catch (  JSONException e) {
    e.printStackTrace();
    result.putBoolean(RESULT_KEY,false);
  }
catch (  CertificateException e) {
    e.printStackTrace();
    result.putBoolean(RESULT_KEY,false);
  }
  try {
    String eip_service_string=downloadWithCommercialCA(eip_service_json_url,danger_on);
    JSONObject eip_service_json=new JSONObject(eip_service_string);
    if (eip_service_json.has(ERRORS)) {
      String reason_to_fail=eip_service_json.getString(ERRORS);
      result.putString(ERRORS,reason_to_fail);
      result.putBoolean(RESULT_KEY,false);
    }
 else {
      ConfigHelper.saveSharedPref(EIP.KEY,eip_service_json);
      ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL,0);
    }
    result.putBoolean(RESULT_KEY,true);
  }
 catch (  JSONException e) {
    result.putBoolean(RESULT_KEY,false);
  }
  return result;
}