nus-yam/ex-repair huggingface dataset:
Program: 109661
Project: 109661
Buggy source:
/** 
 * Tries to download the contents of the provided url using commercially validated CA certificate from chosen provider.
 * @param string_url
 * @return
 */
protected String downloadWithCommercialCA(String string_url){
  String responseString;
  JSONObject errorJson=new JSONObject();
  OkHttpClient okHttpClient=initCommercialCAHttpClient(errorJson);
  if (okHttpClient == null) {
    return errorJson.toString();
  }
  List<Pair<String,String>> headerArgs=getAuthorizationHeader();
  responseString=sendGetStringToServer(string_url,headerArgs,okHttpClient);
  if (responseString.contains(ERRORS)) {
    try {
      JSONObject responseErrorJson=new JSONObject(responseString);
      if (responseErrorJson.getString(ERRORS).equals(getString(R.string.certificate_error))) {
        responseString=downloadWithProviderCA(string_url);
      }
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  return responseString;
}

Fixed version (ground truth):
/** 
 * Tries to download the contents of the provided url using commercially validated CA certificate from chosen provider.
 * @param string_url
 * @return
 */
protected String downloadWithCommercialCA(String string_url){
  String responseString;
  JSONObject errorJson=new JSONObject();
  OkHttpClient okHttpClient=initCommercialCAHttpClient(errorJson);
  if (okHttpClient == null) {
    return errorJson.toString();
  }
  List<Pair<String,String>> headerArgs=getAuthorizationHeader();
  responseString=sendGetStringToServer(string_url,headerArgs,okHttpClient);
  if (responseString != null && responseString.contains(ERRORS)) {
    try {
      JSONObject responseErrorJson=new JSONObject(responseString);
      if (responseErrorJson.getString(ERRORS).equals(getString(R.string.certificate_error))) {
        responseString=downloadWithProviderCA(string_url);
      }
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  return responseString;
}
Program: 109662
Project: 109662
Buggy source:
/** 
 * Downloads a new OpenVPN certificate, attaching authenticated cookie for authenticated certificate.
 * @return true if certificate was downloaded correctly, false if provider.json is not present in SharedPreferences, or if the certificate url could not be parsed as a URI, or if there was an SSL error.
 */
@Override protected boolean updateVpnCertificate(){
  try {
    JSONObject provider_json=new JSONObject(preferences.getString(Provider.KEY,"String_Node_Str"));
    String provider_main_url=provider_json.getString(Provider.API_URL);
    URL new_cert_string_url=new URL(provider_main_url + "String_Node_Str" + provider_json.getString(Provider.API_VERSION)+ "String_Node_Str"+ Constants.VPN_CERTIFICATE);
    String cert_string=downloadWithProviderCA(new_cert_string_url.toString());
    if (cert_string.isEmpty() || ConfigHelper.checkErroneousDownload(cert_string))     return false;
 else     return loadCertificate(cert_string);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
catch (  JSONException e) {
    e.printStackTrace();
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Downloads a new OpenVPN certificate, attaching authenticated cookie for authenticated certificate.
 * @return true if certificate was downloaded correctly, false if provider.json is not present in SharedPreferences, or if the certificate url could not be parsed as a URI, or if there was an SSL error.
 */
@Override protected boolean updateVpnCertificate(){
  try {
    JSONObject provider_json=new JSONObject(preferences.getString(Provider.KEY,"String_Node_Str"));
    String provider_main_url=provider_json.getString(Provider.API_URL);
    URL new_cert_string_url=new URL(provider_main_url + "String_Node_Str" + provider_json.getString(Provider.API_VERSION)+ "String_Node_Str"+ Constants.VPN_CERTIFICATE);
    String cert_string=downloadWithProviderCA(new_cert_string_url.toString());
    if (cert_string == null || cert_string.isEmpty() || ConfigHelper.checkErroneousDownload(cert_string))     return false;
 else     return loadCertificate(cert_string);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
catch (  JSONException e) {
    e.printStackTrace();
    return false;
  }
}
Program: 109663
Project: 109663
Buggy source:
/** 
 * Downloads the eip-service.json from a given URL, and saves eip service capabilities including the offered gateways
 * @return a bundle with a boolean value mapped to a key named RESULT_KEY, and which is true if the download was successful.
 */
@Override protected Bundle getAndSetEipServiceJson(){
  Bundle result=new Bundle();
  String eip_service_json_string="String_Node_Str";
  if (go_ahead) {
    try {
      JSONObject provider_json=new JSONObject(preferences.getString(Provider.KEY,"String_Node_Str"));
      String eip_service_url=provider_json.getString(Provider.API_URL) + "String_Node_Str" + provider_json.getString(Provider.API_VERSION)+ "String_Node_Str"+ EIP.SERVICE_API_PATH;
      eip_service_json_string=downloadWithProviderCA(eip_service_url);
      JSONObject eip_service_json=new JSONObject(eip_service_json_string);
      eip_service_json.getInt(Provider.API_RETURN_SERIAL);
      preferences.edit().putString(Constants.KEY,eip_service_json.toString()).commit();
      result.putBoolean(RESULT_KEY,true);
    }
 catch (    JSONException e) {
      String reason_to_fail=pickErrorMessage(eip_service_json_string);
      result.putString(ERRORS,reason_to_fail);
      result.putBoolean(RESULT_KEY,false);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Downloads the eip-service.json from a given URL, and saves eip service capabilities including the offered gateways
 * @return a bundle with a boolean value mapped to a key named RESULT_KEY, and which is true if the download was successful.
 */
@Override protected Bundle getAndSetEipServiceJson(){
  Bundle result=new Bundle();
  String eip_service_json_string="String_Node_Str";
  if (go_ahead) {
    try {
      JSONObject provider_json=new JSONObject(preferences.getString(Provider.KEY,"String_Node_Str"));
      String eip_service_url=provider_json.getString(Provider.API_URL) + "String_Node_Str" + provider_json.getString(Provider.API_VERSION)+ "String_Node_Str"+ EIP.SERVICE_API_PATH;
      eip_service_json_string=downloadWithProviderCA(eip_service_url);
      JSONObject eip_service_json=new JSONObject(eip_service_json_string);
      eip_service_json.getInt(Provider.API_RETURN_SERIAL);
      preferences.edit().putString(Constants.KEY,eip_service_json.toString()).commit();
      result.putBoolean(RESULT_KEY,true);
    }
 catch (    NullPointerException|JSONException e) {
      String reason_to_fail=pickErrorMessage(eip_service_json_string);
      result.putString(ERRORS,reason_to_fail);
      result.putBoolean(RESULT_KEY,false);
    }
  }
  return result;
}
Program: 109664
Project: 109664
Buggy source:
public boolean errorInLast(int lines,Context context){
  boolean result=false;
  String[] error_keywords={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  VpnStatus.LogItem[] log=VpnStatus.getlogbuffer();
  String message="String_Node_Str";
  for (int i=0; i < lines; i++) {
    message=log[log.length - 1].getString(context);
    for (int j=0; j < error_keywords.length; j++)     if (message.contains(error_keywords[i]))     result=true;
  }
  return result;
}

Fixed version (ground truth):
public boolean errorInLast(int lines,Context context){
  boolean result=false;
  String[] error_keywords={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  VpnStatus.LogItem[] log=VpnStatus.getlogbuffer();
  String message="String_Node_Str";
  for (int i=0; i < lines; i++) {
    message=log[log.length - i].getString(context);
    for (int j=0; j < error_keywords.length; j++)     if (message.contains(error_keywords[j]))     result=true;
  }
  return result;
}
Program: 109665
Project: 109665
Buggy source:
/** 
 * Open the new provider dialog with data
 */
public void addAndSelectNewProvider(String main_url,boolean danger_on){
  FragmentTransaction fragment_transaction=fragment_manager.removePreviousFragment(NewProviderDialog.TAG);
  DialogFragment newFragment=NewProviderDialog.newInstance();
  Bundle data=new Bundle();
  data.putString(Provider.MAIN_URL,main_url);
  data.putBoolean(ProviderItem.DANGER_ON,danger_on);
  newFragment.setArguments(data);
  newFragment.show(fragment_transaction,NewProviderDialog.TAG);
}

Fixed version (ground truth):
/** 
 * Open the new provider dialog with data
 */
public void addAndSelectNewProvider(String main_url,boolean danger_on){
  FragmentTransaction fragment_transaction=fragment_manager.removePreviousFragment(NewProviderDialog.TAG);
  DialogFragment newFragment=new NewProviderDialog();
  Bundle data=new Bundle();
  data.putString(Provider.MAIN_URL,main_url);
  data.putBoolean(ProviderItem.DANGER_ON,danger_on);
  newFragment.setArguments(data);
  newFragment.show(fragment_transaction,NewProviderDialog.TAG);
}
Program: 109666
Project: 109666
Buggy source:
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  LayoutInflater inflater=getActivity().getLayoutInflater();
  View new_provider_dialog_view=inflater.inflate(R.layout.new_provider_dialog,null);
  final EditText url_input_field=(EditText)new_provider_dialog_view.findViewById(R.id.new_provider_url);
  if (getArguments() != null && getArguments().containsKey(Provider.MAIN_URL)) {
    url_input_field.setText(getArguments().getString(Provider.MAIN_URL));
  }
  final CheckBox danger_checkbox=(CheckBox)new_provider_dialog_view.findViewById(R.id.danger_checkbox);
  if (getArguments() != null && getArguments().containsKey(ProviderItem.DANGER_ON)) {
    danger_checkbox.setActivated(getArguments().getBoolean(ProviderItem.DANGER_ON));
  }
  builder.setView(new_provider_dialog_view).setMessage(R.string.introduce_new_provider).setPositiveButton(R.string.save,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      String entered_url=url_input_field.getText().toString().trim();
      if (!entered_url.startsWith("String_Node_Str")) {
        if (entered_url.startsWith("String_Node_Str")) {
          entered_url=entered_url.substring("String_Node_Str".length());
        }
        entered_url="String_Node_Str".concat(entered_url);
      }
      boolean danger_on=danger_checkbox.isChecked();
      if (validURL(entered_url)) {
        interface_with_ConfigurationWizard.showAndSelectProvider(entered_url,danger_on);
        Toast.makeText(getActivity().getApplicationContext(),R.string.valid_url_entered,Toast.LENGTH_LONG).show();
      }
 else {
        url_input_field.setText("String_Node_Str");
        danger_checkbox.setChecked(false);
        Toast.makeText(getActivity().getApplicationContext(),R.string.not_valid_url_entered,Toast.LENGTH_LONG).show();
        ;
      }
    }
  }
).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
);
  return builder.create();
}

Fixed version (ground truth):
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  LayoutInflater inflater=getActivity().getLayoutInflater();
  View view=inflater.inflate(R.layout.new_provider_dialog,null);
  ButterKnife.inject(this,view);
  Bundle arguments=getArguments();
  if (arguments != null) {
    url_input_field.setText(arguments.getString(Provider.MAIN_URL,"String_Node_Str"));
    danger_checkbox.setActivated(arguments.getBoolean(ProviderItem.DANGER_ON,false));
  }
  builder.setView(view).setMessage(R.string.introduce_new_provider).setPositiveButton(R.string.save,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      saveProvider();
    }
  }
).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
);
  return builder.create();
}
Program: 109667
Project: 109667
Buggy source:
@Override public void add(Provider item){
  super.add(item);
  if (getCollection().size() < hidden.length) {
    boolean[] new_hidden=new boolean[hidden.length + 1];
    System.arraycopy(hidden,0,new_hidden,0,hidden.length);
    new_hidden[hidden.length]=false;
    hidden=new_hidden;
  }
}

Fixed version (ground truth):
@Override public void add(Provider item){
  super.add(item);
  if (getCollection().size() > hidden.length) {
    boolean[] new_hidden=new boolean[hidden.length + 1];
    System.arraycopy(hidden,0,new_hidden,0,hidden.length);
    new_hidden[hidden.length]=false;
    hidden=new_hidden;
  }
}
Program: 109668
Project: 109668
Buggy source:
/** 
 * Open the new provider dialog with data
 */
public void addAndSelectNewProvider(String main_url){
  FragmentTransaction fragment_transaction=fragment_manager.removePreviousFragment(NewProviderDialog.TAG);
  DialogFragment newFragment=NewProviderDialog.newInstance();
  Bundle data=new Bundle();
  data.putString(Provider.MAIN_URL,main_url);
  newFragment.setArguments(data);
  newFragment.show(fragment_transaction,NewProviderDialog.TAG);
}

Fixed version (ground truth):
/** 
 * Open the new provider dialog with data
 */
public void addAndSelectNewProvider(String main_url){
  FragmentTransaction fragment_transaction=fragment_manager.removePreviousFragment(NewProviderDialog.TAG);
  DialogFragment newFragment=new NewProviderDialog();
  Bundle data=new Bundle();
  data.putString(Provider.MAIN_URL,main_url);
  newFragment.setArguments(data);
  newFragment.show(fragment_transaction,NewProviderDialog.TAG);
}
Program: 109669
Project: 109669
Buggy source:
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  LayoutInflater inflater=getActivity().getLayoutInflater();
  View new_provider_dialog_view=inflater.inflate(R.layout.new_provider_dialog,null);
  final EditText url_input_field=(EditText)new_provider_dialog_view.findViewById(R.id.new_provider_url);
  if (getArguments() != null && getArguments().containsKey(Provider.MAIN_URL)) {
    url_input_field.setText(getArguments().getString(Provider.MAIN_URL));
  }
  builder.setView(new_provider_dialog_view).setMessage(R.string.introduce_new_provider).setPositiveButton(R.string.save,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      String entered_url=url_input_field.getText().toString().trim();
      if (!entered_url.startsWith("String_Node_Str")) {
        if (entered_url.startsWith("String_Node_Str")) {
          entered_url=entered_url.substring("String_Node_Str".length());
        }
        entered_url="String_Node_Str".concat(entered_url);
      }
      if (validURL(entered_url)) {
        interface_with_ConfigurationWizard.showAndSelectProvider(entered_url);
        Toast.makeText(getActivity().getApplicationContext(),R.string.valid_url_entered,Toast.LENGTH_LONG).show();
      }
 else {
        url_input_field.setText("String_Node_Str");
        Toast.makeText(getActivity().getApplicationContext(),R.string.not_valid_url_entered,Toast.LENGTH_LONG).show();
        ;
      }
    }
  }
).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
);
  return builder.create();
}

Fixed version (ground truth):
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  LayoutInflater inflater=getActivity().getLayoutInflater();
  View view=inflater.inflate(R.layout.new_provider_dialog,null);
  ButterKnife.inject(this,view);
  Bundle arguments=getArguments();
  if (arguments != null) {
    url_input_field.setText(arguments.getString(Provider.MAIN_URL,"String_Node_Str"));
  }
  builder.setView(view).setMessage(R.string.introduce_new_provider).setPositiveButton(R.string.save,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      saveProvider();
    }
  }
).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
);
  return builder.create();
}
Program: 109670
Project: 109670
Buggy source:
public void testExponential(){
  byte[] expected_A;
  byte[] a_byte;
  SRPParameters params;
  LeapSRPSession client;
  expected_A=new BigInteger("String_Node_Str",16).toByteArray();
  String username="String_Node_Str", password="String_Node_Str", salt="String_Node_Str", a="String_Node_Str";
  a_byte=new BigInteger(a,16).toByteArray();
  params=new SRPParameters(new BigInteger(ConfigHelper.NG_1024,16).toByteArray(),new BigInteger("String_Node_Str").toByteArray(),new BigInteger(salt,16).toByteArray(),"String_Node_Str");
  client=new LeapSRPSession(username,password,params,a_byte);
  byte[] A=client.exponential();
  assertTrue(Arrays.equals(A,expected_A));
  a="String_Node_Str";
  expected_A=new BigInteger("String_Node_Str",16).toByteArray();
  a_byte=new BigInteger(a,16).toByteArray();
  params=new SRPParameters(new BigInteger(ConfigHelper.NG_1024,16).toByteArray(),new BigInteger("String_Node_Str").toByteArray(),new BigInteger(salt,16).toByteArray(),"String_Node_Str");
  client=new LeapSRPSession(username,password,params,a_byte);
  A=client.exponential();
  assertTrue(Arrays.equals(A,expected_A));
}

Fixed version (ground truth):
public void testExponential(){
  byte[] expected_A;
  byte[] a_byte;
  LeapSRPSession client;
  expected_A=new BigInteger("String_Node_Str",16).toByteArray();
  String username="String_Node_Str", password="String_Node_Str", salt="String_Node_Str", a="String_Node_Str";
  a_byte=new BigInteger(a,16).toByteArray();
  client=new LeapSRPSession(username,password,a_byte);
  byte[] A=client.exponential();
  assertTrue(Arrays.equals(A,expected_A));
  a="String_Node_Str";
  expected_A=new BigInteger("String_Node_Str",16).toByteArray();
  a_byte=new BigInteger(a,16).toByteArray();
  client=new LeapSRPSession(username,password,a_byte);
  A=client.exponential();
  assertTrue(Arrays.equals(A,expected_A));
}
Program: 109672
Project: 109672
Buggy source:
public void testSignUpMath() throws NoSuchAlgorithmException {
  String username="String_Node_Str";
  String password="String_Node_Str";
  byte[] salt=new BigInteger("String_Node_Str",16).toByteArray();
  SRPParameters params=new SRPParameters(new BigInteger(ConfigHelper.NG_1024,16).toByteArray(),new BigInteger("String_Node_Str").toByteArray(),salt,"String_Node_Str");
  LeapSRPSession client=new LeapSRPSession(username,password,params);
  String expected_v="String_Node_Str";
  assertEquals(expected_v,client.calculateV(username,password,salt).toString(16));
}

Fixed version (ground truth):
public void testSignUpMath() throws NoSuchAlgorithmException {
  String username="String_Node_Str";
  String password="String_Node_Str";
  byte[] salt=new BigInteger("String_Node_Str",16).toByteArray();
  LeapSRPSession client=new LeapSRPSession(username,password);
  String expected_v="String_Node_Str";
  assertEquals(expected_v,client.calculateV(username,password,salt).toString(16));
}
Program: 109674
Project: 109674
Buggy source:
private boolean loadCertificate(String cert_string){
  try {
    String certificateString=null, keyString=null;
    String[] certAndKey=cert_string.split("String_Node_Str");
    for (int i=0; i < certAndKey.length - 1; i++) {
      if (certAndKey[i].contains("String_Node_Str")) {
        keyString=certAndKey[i++] + certAndKey[i];
      }
 else       if (certAndKey[i].contains("String_Node_Str")) {
        certificateString=certAndKey[i++] + certAndKey[i];
      }
    }
    RSAPrivateKey keyCert=ConfigHelper.parseRsaKeyFromString(keyString);
    keyString=Base64.encodeToString(keyCert.getEncoded(),Base64.DEFAULT);
    preferences.edit().putString(Constants.PRIVATE_KEY,"String_Node_Str" + keyString + "String_Node_Str").commit();
    X509Certificate certCert=ConfigHelper.parseX509CertificateFromString(certificateString);
    certificateString=Base64.encodeToString(certCert.getEncoded(),Base64.DEFAULT);
    preferences.edit().putString(Constants.CERTIFICATE,"String_Node_Str" + certificateString + "String_Node_Str").commit();
    preferences.edit().putString(Constants.DATE_FROM_CERTIFICATE,EIP.certificate_date_format.format(Calendar.getInstance().getTime())).commit();
    return true;
  }
 catch (  CertificateException e) {
    e.printStackTrace();
    return false;
  }
}

Fixed version (ground truth):
private boolean loadCertificate(String cert_string){
  try {
    String certificateString=null, keyString=null;
    String[] certAndKey=cert_string.split("String_Node_Str");
    for (int i=0; i < certAndKey.length - 1; i++) {
      if (certAndKey[i].contains("String_Node_Str")) {
        keyString=certAndKey[i++] + certAndKey[i];
      }
 else       if (certAndKey[i].contains("String_Node_Str")) {
        certificateString=certAndKey[i++] + certAndKey[i];
      }
    }
    RSAPrivateKey keyCert=ConfigHelper.parseRsaKeyFromString(keyString);
    keyString=Base64.encodeToString(keyCert.getEncoded(),Base64.DEFAULT);
    preferences.edit().putString(Constants.PRIVATE_KEY,"String_Node_Str" + keyString + "String_Node_Str").commit();
    X509Certificate certCert=ConfigHelper.parseX509CertificateFromString(certificateString);
    certificateString=Base64.encodeToString(certCert.getEncoded(),Base64.DEFAULT);
    preferences.edit().putString(Constants.CERTIFICATE,"String_Node_Str" + certificateString + "String_Node_Str").commit();
    return true;
  }
 catch (  CertificateException e) {
    e.printStackTrace();
    return false;
  }
}
Program: 109675
Project: 109675
Buggy source:
@Override public void run(){
  try {
    Log.i(TAG,"String_Node_Str");
    startOpenVPNThreadArgs(mArgv);
    Log.i(TAG,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
    Log.e(TAG,"String_Node_Str" + e.toString());
  }
 finally {
    int exitvalue=0;
    try {
      exitvalue=mProcess.waitFor();
    }
 catch (    IllegalThreadStateException ite) {
      OpenVPN.logError("String_Node_Str" + ite.getLocalizedMessage());
    }
catch (    InterruptedException ie) {
      OpenVPN.logError("String_Node_Str" + ie.getLocalizedMessage());
    }
    if (exitvalue != 0)     OpenVPN.logError("String_Node_Str" + exitvalue);
    OpenVPN.updateStateString("String_Node_Str","String_Node_Str",R.string.state_noprocess);
    if (mDumpPath != null) {
      try {
        BufferedWriter logout=new BufferedWriter(new FileWriter(mDumpPath + "String_Node_Str"));
        for (        LogItem li : OpenVPN.getlogbuffer()) {
          logout.write(li.getString(null) + "String_Node_Str");
        }
        logout.close();
        OpenVPN.logError(R.string.minidump_generated);
      }
 catch (      IOException e) {
        OpenVPN.logError("String_Node_Str" + e.getLocalizedMessage());
      }
    }
    mService.processDied();
    Log.i(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Log.i(TAG,"String_Node_Str");
    startOpenVPNThreadArgs(mArgv);
    Log.i(TAG,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
    Log.e(TAG,"String_Node_Str" + e.toString());
  }
 finally {
    int exitvalue=0;
    try {
      exitvalue=mProcess.waitFor();
    }
 catch (    IllegalThreadStateException ite) {
      OpenVPN.logError("String_Node_Str" + ite.getLocalizedMessage());
    }
catch (    InterruptedException ie) {
      OpenVPN.logError("String_Node_Str" + ie.getLocalizedMessage());
    }
    if (exitvalue != 0)     OpenVPN.logError("String_Node_Str" + exitvalue);
    if (mDumpPath != null) {
      try {
        BufferedWriter logout=new BufferedWriter(new FileWriter(mDumpPath + "String_Node_Str"));
        for (        LogItem li : OpenVPN.getlogbuffer()) {
          logout.write(li.getString(null) + "String_Node_Str");
        }
        logout.close();
        OpenVPN.logError(R.string.minidump_generated);
      }
 catch (      IOException e) {
        OpenVPN.logError("String_Node_Str" + e.getLocalizedMessage());
      }
    }
    mService.processDied();
    Log.i(TAG,"String_Node_Str");
  }
}
Program: 109678
Project: 109678
Buggy source:
/** 
 * Checks if the entered url is valid or not.
 * @param entered_url
 * @return true if it's not empty nor contains only the protocol.
 */
boolean validURL(String entered_url){
  return !entered_url.isEmpty() && entered_url.matches("String_Node_Str") && !entered_url.replaceFirst("String_Node_Str","String_Node_Str").isEmpty();
}

Fixed version (ground truth):
/** 
 * Checks if the entered url is valid or not.
 * @param entered_url
 * @return true if it's not empty nor contains only the protocol.
 */
boolean validURL(String entered_url){
  return android.util.Patterns.WEB_URL.matcher(entered_url).matches();
}
Program: 109679
Project: 109679
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) {
    if (resultCode == RESULT_OK) {
      ConfigHelper.saveSharedPref(EIP.AUTHED_EIP,authed_eip);
      startService(new Intent(EIP.ACTION_UPDATE_EIP_SERVICE));
      buildDashboard();
      if (data != null && data.hasExtra(LogInDialog.VERB)) {
        View view=((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
        logInDialog(view,Bundle.EMPTY);
      }
    }
 else     if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) {
      finish();
    }
 else     configErrorDialog();
  }
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) {
    if (resultCode == RESULT_OK) {
      ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL,0);
      ConfigHelper.saveSharedPref(EIP.AUTHED_EIP,authed_eip);
      startService(new Intent(EIP.ACTION_UPDATE_EIP_SERVICE));
      buildDashboard();
      if (data != null && data.hasExtra(LogInDialog.VERB)) {
        View view=((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
        logInDialog(view,Bundle.EMPTY);
      }
    }
 else     if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) {
      finish();
    }
 else     configErrorDialog();
  }
}
Program: 109680
Project: 109680
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  Intent intent;
switch (item.getItemId()) {
case R.id.about_leap:
    Fragment aboutFragment=new AboutFragment();
  FragmentTransaction trans=getFragmentManager().beginTransaction();
trans.replace(R.id.dashboardLayout,aboutFragment);
trans.addToBackStack(null);
trans.commit();
return true;
case R.id.legacy_interface:
intent=new Intent(this,MainActivity.class);
startActivity(intent);
return true;
case R.id.switch_provider:
startActivityForResult(new Intent(this,ConfigurationWizard.class),SWITCH_PROVIDER);
return true;
case R.id.login_button:
View view=((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
logInDialog(view,Bundle.EMPTY);
return true;
case R.id.logout_button:
logOut();
return true;
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  Intent intent;
switch (item.getItemId()) {
case R.id.about_leap:
    Fragment aboutFragment=new AboutFragment();
  FragmentTransaction trans=getFragmentManager().beginTransaction();
trans.replace(R.id.dashboardLayout,aboutFragment);
trans.addToBackStack(null);
trans.commit();
return true;
case R.id.legacy_interface:
intent=new Intent(this,MainActivity.class);
startActivity(intent);
return true;
case R.id.switch_provider:
if (Provider.getInstance().hasEIP()) {
if (ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP)) {
logOut();
}
eipStop();
}
startActivityForResult(new Intent(this,ConfigurationWizard.class),SWITCH_PROVIDER);
return true;
case R.id.login_button:
View view=((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
logInDialog(view,Bundle.EMPTY);
return true;
case R.id.logout_button:
logOut();
return true;
default :
return super.onOptionsItemSelected(item);
}
}
Program: 109681
Project: 109681
Buggy source:
/** 
 * Loads eip-service.json from SharedPreferences and calls   {@link updateGateways()}to parse gateway definitions. TODO Implement API call to refresh eip-service.json from the provider
 */
private void updateEIPService(){
  try {
    eipDefinition=ConfigHelper.getJsonFromSharedPref(EIP.KEY);
  }
 catch (  JSONException e) {
    e.printStackTrace();
  }
  if (eipDefinition.optInt("String_Node_Str") > parsedEipSerial)   updateGateways();
}

Fixed version (ground truth):
/** 
 * Loads eip-service.json from SharedPreferences and calls   {@link updateGateways()}to parse gateway definitions. TODO Implement API call to refresh eip-service.json from the provider
 */
private void updateEIPService(){
  try {
    eipDefinition=ConfigHelper.getJsonFromSharedPref(EIP.KEY);
    parsedEipSerial=ConfigHelper.getIntFromSharedPref(PARSED_SERIAL);
  }
 catch (  JSONException e) {
    e.printStackTrace();
  }
  if (parsedEipSerial == 0) {
    ProfileManager vpl=ProfileManager.getInstance(context);
    Collection<VpnProfile> profiles=vpl.getProfiles();
    for (    VpnProfile profile : profiles) {
      vpl.removeProfile(context,profile);
    }
  }
  if (eipDefinition.optInt("String_Node_Str") > parsedEipSerial)   updateGateways();
}
Program: 109682
Project: 109682
Buggy source:
/** 
 * Initiates an EIP connection by selecting a gateway and preparing and sending an Intent to   {@link se.leap.openvpn.LaunchVPN}
 */
private void startEIP(){
  if (activeGateway == null)   activeGateway=selectGateway();
  Intent intent=new Intent(this,LaunchVPN.class);
  intent.setAction(Intent.ACTION_MAIN);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(LaunchVPN.EXTRA_KEY,activeGateway.mVpnProfile.getUUID().toString());
  intent.putExtra(LaunchVPN.EXTRA_NAME,activeGateway.mVpnProfile.getName());
  intent.putExtra(RECEIVER_TAG,mReceiver);
  startActivity(intent);
  mPending=ACTION_START_EIP;
}

Fixed version (ground truth):
/** 
 * Initiates an EIP connection by selecting a gateway and preparing and sending an Intent to   {@link se.leap.openvpn.LaunchVPN}
 */
private void startEIP(){
  activeGateway=selectGateway();
  Intent intent=new Intent(this,LaunchVPN.class);
  intent.setAction(Intent.ACTION_MAIN);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(LaunchVPN.EXTRA_KEY,activeGateway.mVpnProfile.getUUID().toString());
  intent.putExtra(LaunchVPN.EXTRA_NAME,activeGateway.mVpnProfile.getName());
  intent.putExtra(RECEIVER_TAG,mReceiver);
  startActivity(intent);
  mPending=ACTION_START_EIP;
}
Program: 109683
Project: 109683
Buggy source:
@Override public void updateState(final String state,final String logmessage,final int localizedResId){
  getActivity().runOnUiThread(new Runnable(){
    @Override public void run(){
      if (eipStatus != null) {
        boolean switchState=true;
        String statusMessage="String_Node_Str";
        String prefix=getString(localizedResId);
        if (state.equals("String_Node_Str")) {
          statusMessage=getString(R.string.eip_state_connected);
          getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
          mEipStartPending=false;
        }
 else         if (state.equals("String_Node_Str")) {
          statusMessage=getString(R.string.eip_state_connected);
          getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
          mEipStartPending=false;
        }
 else         if ((state.equals("String_Node_Str") && !mEipStartPending) || state.equals("String_Node_Str")) {
          statusMessage=getString(R.string.eip_state_not_connected);
          getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
          mEipStartPending=false;
          switchState=false;
        }
 else         if (state.equals("String_Node_Str")) {
          statusMessage=logmessage;
        }
 else {
          statusMessage=prefix + "String_Node_Str" + logmessage;
        }
        eipAutoSwitched=true;
        eipSwitch.setChecked(switchState);
        eipAutoSwitched=false;
        eipStatus.setText(statusMessage);
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void updateState(final String state,final String logmessage,final int localizedResId){
  getActivity().runOnUiThread(new Runnable(){
    @Override public void run(){
      if (eipStatus != null) {
        boolean switchState=true;
        String statusMessage="String_Node_Str";
        String prefix=getString(localizedResId);
        if (state.equals("String_Node_Str")) {
          statusMessage=getString(R.string.eip_state_connected);
          getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
          mEipStartPending=false;
        }
 else         if (state.equals("String_Node_Str")) {
          statusMessage=getString(R.string.eip_state_connected);
          getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
          mEipStartPending=false;
        }
 else         if ((state.equals("String_Node_Str") && !mEipStartPending) || state.equals("String_Node_Str") || state.equals("String_Node_Str")) {
          statusMessage=getString(R.string.eip_state_not_connected);
          getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
          mEipStartPending=false;
          switchState=false;
        }
 else         if (state.equals("String_Node_Str")) {
          statusMessage=logmessage;
        }
 else {
          statusMessage=prefix + "String_Node_Str" + logmessage;
        }
        eipAutoSwitched=true;
        eipSwitch.setChecked(switchState);
        eipAutoSwitched=false;
        eipStatus.setText(statusMessage);
      }
    }
  }
);
}
Program: 109684
Project: 109684
Buggy source:
@Override public void run(){
  if (eipStatus != null) {
    boolean switchState=true;
    String statusMessage="String_Node_Str";
    String prefix=getString(localizedResId);
    if (state.equals("String_Node_Str")) {
      statusMessage=getString(R.string.eip_state_connected);
      getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
      mEipStartPending=false;
    }
 else     if (state.equals("String_Node_Str")) {
      statusMessage=getString(R.string.eip_state_connected);
      getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
      mEipStartPending=false;
    }
 else     if ((state.equals("String_Node_Str") && !mEipStartPending) || state.equals("String_Node_Str")) {
      statusMessage=getString(R.string.eip_state_not_connected);
      getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
      mEipStartPending=false;
      switchState=false;
    }
 else     if (state.equals("String_Node_Str")) {
      statusMessage=logmessage;
    }
 else {
      statusMessage=prefix + "String_Node_Str" + logmessage;
    }
    eipAutoSwitched=true;
    eipSwitch.setChecked(switchState);
    eipAutoSwitched=false;
    eipStatus.setText(statusMessage);
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (eipStatus != null) {
    boolean switchState=true;
    String statusMessage="String_Node_Str";
    String prefix=getString(localizedResId);
    if (state.equals("String_Node_Str")) {
      statusMessage=getString(R.string.eip_state_connected);
      getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
      mEipStartPending=false;
    }
 else     if (state.equals("String_Node_Str")) {
      statusMessage=getString(R.string.eip_state_connected);
      getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
      mEipStartPending=false;
    }
 else     if ((state.equals("String_Node_Str") && !mEipStartPending) || state.equals("String_Node_Str") || state.equals("String_Node_Str")) {
      statusMessage=getString(R.string.eip_state_not_connected);
      getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
      mEipStartPending=false;
      switchState=false;
    }
 else     if (state.equals("String_Node_Str")) {
      statusMessage=logmessage;
    }
 else {
      statusMessage=prefix + "String_Node_Str" + logmessage;
    }
    eipAutoSwitched=true;
    eipSwitch.setChecked(switchState);
    eipAutoSwitched=false;
    eipStatus.setText(statusMessage);
  }
}
Program: 109685
Project: 109685
Buggy source:
protected boolean hasEIP(){
  JSONArray services=null;
  try {
    services=definition.getJSONArray(API_TERM_SERVICES);
  }
 catch (  Exception e) {
  }
  for (int i=0; i < API_EIP_TYPES.length + 1; i++) {
    try {
      if (Arrays.asList(API_EIP_TYPES).contains(services.getString(i)))       return true;
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  return false;
}

Fixed version (ground truth):
protected boolean hasEIP(){
  JSONArray services=null;
  try {
    services=definition.getJSONArray(API_TERM_SERVICES);
  }
 catch (  Exception e) {
  }
  for (int i=0; i < API_EIP_TYPES.length + 1; i++) {
    try {
      if (Arrays.asList(API_EIP_TYPES).contains(services.getString(i)))       return true;
    }
 catch (    NullPointerException e) {
      e.printStackTrace();
    }
catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  return false;
}
Program: 109687
Project: 109687
Buggy source:
private static int getLocalizedState(String state){
  if (state.equals("String_Node_Str"))   return R.string.state_connecting;
 else   if (state.equals("String_Node_Str"))   return R.string.state_wait;
 else   if (state.equals("String_Node_Str"))   return R.string.state_auth;
 else   if (state.equals("String_Node_Str"))   return R.string.state_get_config;
 else   if (state.equals("String_Node_Str"))   return R.string.state_assign_ip;
 else   if (state.equals("String_Node_Str"))   return R.string.state_add_routes;
 else   if (state.equals("String_Node_Str"))   return R.string.state_connected;
 else   if (state.equals("String_Node_Str"))   return R.string.state_reconnecting;
 else   if (state.equals("String_Node_Str"))   return R.string.state_exiting;
 else   if (state.equals("String_Node_Str"))   return R.string.state_resolve;
 else   if (state.equals("String_Node_Str"))   return R.string.state_tcp_connect;
 else   return R.string.unknown_state;
}

Fixed version (ground truth):
private static int getLocalizedState(String state){
  if (state.equals("String_Node_Str"))   return R.string.state_connecting;
 else   if (state.equals("String_Node_Str"))   return R.string.state_wait;
 else   if (state.equals("String_Node_Str"))   return R.string.state_auth;
 else   if (state.equals("String_Node_Str"))   return R.string.state_get_config;
 else   if (state.equals("String_Node_Str"))   return R.string.state_assign_ip;
 else   if (state.equals("String_Node_Str"))   return R.string.state_add_routes;
 else   if (state.equals("String_Node_Str"))   return R.string.state_connected;
 else   if (state.equals("String_Node_Str"))   return R.string.state_reconnecting;
 else   if (state.equals("String_Node_Str"))   return R.string.state_exiting;
 else   if (state.equals("String_Node_Str"))   return R.string.state_resolve;
 else   if (state.equals("String_Node_Str"))   return R.string.state_tcp_connect;
 else   if (state.equals("String_Node_Str"))   return R.string.eip_state_not_connected;
 else   return R.string.unknown_state;
}
Program: 109688
Project: 109688
Buggy source:
@Override public void run(){
  try {
    Log.i(TAG,"String_Node_Str");
    startOpenVPNThreadArgs(mArgv);
    Log.i(TAG,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
    Log.e(TAG,"String_Node_Str" + e.toString());
  }
 finally {
    int exitvalue=0;
    try {
      exitvalue=mProcess.waitFor();
    }
 catch (    IllegalThreadStateException ite) {
      OpenVPN.logError("String_Node_Str" + ite.getLocalizedMessage());
    }
catch (    InterruptedException ie) {
      OpenVPN.logError("String_Node_Str" + ie.getLocalizedMessage());
    }
    if (exitvalue != 0)     OpenVPN.logError("String_Node_Str" + exitvalue);
    OpenVPN.updateStateString("String_Node_Str","String_Node_Str",R.string.state_noprocess);
    if (mDumpPath != null) {
      try {
        BufferedWriter logout=new BufferedWriter(new FileWriter(mDumpPath + "String_Node_Str"));
        for (        LogItem li : OpenVPN.getlogbuffer()) {
          logout.write(li.getString(null) + "String_Node_Str");
        }
        logout.close();
        OpenVPN.logError(R.string.minidump_generated);
      }
 catch (      IOException e) {
        OpenVPN.logError("String_Node_Str" + e.getLocalizedMessage());
      }
    }
    mService.processDied();
    Log.i(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Log.i(TAG,"String_Node_Str");
    startOpenVPNThreadArgs(mArgv);
    Log.i(TAG,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
    Log.e(TAG,"String_Node_Str" + e.toString());
  }
 finally {
    int exitvalue=0;
    try {
      exitvalue=mProcess.waitFor();
    }
 catch (    IllegalThreadStateException ite) {
      OpenVPN.logError("String_Node_Str" + ite.getLocalizedMessage());
    }
catch (    InterruptedException ie) {
      OpenVPN.logError("String_Node_Str" + ie.getLocalizedMessage());
    }
    if (exitvalue != 0)     OpenVPN.logError("String_Node_Str" + exitvalue);
    if (mDumpPath != null) {
      try {
        BufferedWriter logout=new BufferedWriter(new FileWriter(mDumpPath + "String_Node_Str"));
        for (        LogItem li : OpenVPN.getlogbuffer()) {
          logout.write(li.getString(null) + "String_Node_Str");
        }
        logout.close();
        OpenVPN.logError(R.string.minidump_generated);
      }
 catch (      IOException e) {
        OpenVPN.logError("String_Node_Str" + e.getLocalizedMessage());
      }
    }
    mService.processDied();
    Log.i(TAG,"String_Node_Str");
  }
}
Program: 109690
Project: 109690
Buggy source:
public void testLogInAndOut(){
  long miliseconds_to_log_in=40 * 1000;
  solo.clickOnMenuItem("String_Node_Str");
  solo.enterText(0,"String_Node_Str");
  solo.enterText(1,"String_Node_Str");
  solo.clickOnText("String_Node_Str");
  solo.waitForDialogToClose();
  solo.waitForDialogToClose(miliseconds_to_log_in);
  if (!solo.waitForText("String_Node_Str"))   fail();
  solo.clickOnMenuItem("String_Node_Str");
  if (!solo.waitForDialogToClose())   fail();
}

Fixed version (ground truth):
public void testLogInAndOut(){
  long miliseconds_to_log_in=40 * 1000;
  solo.clickOnActionBarItem(R.id.login_button);
  solo.enterText(0,"String_Node_Str");
  solo.enterText(1,"String_Node_Str");
  solo.clickOnText("String_Node_Str");
  solo.waitForDialogToClose();
  solo.waitForDialogToClose(miliseconds_to_log_in);
  if (!solo.waitForText("String_Node_Str"))   fail();
  solo.clickOnActionBarItem(R.string.logout_button);
  if (!solo.waitForDialogToClose())   fail();
}
Program: 109691
Project: 109691
Buggy source:
public void testShowAbout(){
  solo.clickOnMenuItem("String_Node_Str");
  solo.waitForText("String_Node_Str");
  solo.goBack();
  solo.clickOnMenuItem("String_Node_Str");
  solo.waitForText("String_Node_Str");
  solo.goBack();
}

Fixed version (ground truth):
public void testShowAbout(){
  solo.clickOnMenuItem("String_Node_Str");
  solo.waitForText(getActivity().getString(R.string.repository_url_text));
  solo.goBack();
  solo.clickOnMenuItem("String_Node_Str");
  solo.waitForText(getActivity().getString(R.string.repository_url_text));
  solo.goBack();
}
Program: 109692
Project: 109692
Buggy source:
/** 
 * This test will fail if Android does not trust VPN connection. I cannot automate that dialog.
 */
public void testOnOffOpenVpn(){
  solo.clickOnView(solo.getView(R.id.eipSwitch));
  if (!solo.waitForText("String_Node_Str"))   fail();
  if (!solo.waitForText("String_Node_Str"))   fail();
  if (!solo.waitForText("String_Node_Str",1,30 * 1000))   fail();
  solo.clickOnView(solo.getView(R.id.eipSwitch));
  if (!solo.waitForText("String_Node_Str"))   fail();
  setAirplaneMode(true);
  if (!solo.waitForLogMessage("String_Node_Str"))   fail();
  solo.clickOnView(solo.getView(R.id.eipSwitch));
  if (!solo.waitForText("String_Node_Str"))   fail();
  if (!solo.waitForText("String_Node_Str"))   fail();
}

Fixed version (ground truth):
/** 
 * This test will fail if Android does not trust VPN connection. I cannot automate that dialog.
 */
public void testOnOffOpenVpn(){
  solo.clickOnView(solo.getView(R.id.eipSwitch));
  if (!solo.waitForText("String_Node_Str"))   fail();
  if (!solo.waitForText("String_Node_Str"))   fail();
  if (!solo.waitForText("String_Node_Str",1,30 * 1000))   fail();
  solo.clickOnView(solo.getView(R.id.eipSwitch));
  if (!solo.waitForText("String_Node_Str"))   fail();
}
Program: 109693
Project: 109693
Buggy source:
public void testShowSettings(){
  solo.clickOnMenuItem("String_Node_Str");
}

Fixed version (ground truth):
public void testShowSettings(){
  solo.clickOnActionBarItem(R.id.menu_settings);
}
Program: 109695
Project: 109695
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  app=this;
  ConfigHelper.setSharedPreferences(getSharedPreferences(SHARED_PREFERENCES,MODE_PRIVATE));
  preferences=ConfigHelper.shared_preferences;
  if (ConfigHelper.getStringFromSharedPref(Provider.KEY).isEmpty())   startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
 else   buildDashboard();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  app=this;
  PRNGFixes.apply();
  ConfigHelper.setSharedPreferences(getSharedPreferences(SHARED_PREFERENCES,MODE_PRIVATE));
  preferences=ConfigHelper.shared_preferences;
  if (ConfigHelper.getStringFromSharedPref(Provider.KEY).isEmpty())   startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
 else   buildDashboard();
}
Program: 109696
Project: 109696
Buggy source:
/** 
 * Dialog shown when encountering a configuration error.  Such errors require reconfiguring LEAP or aborting the application.
 */
private void configErrorDialog(){
  AlertDialog.Builder alertBuilder=new AlertDialog.Builder(getAppContext());
  alertBuilder.setTitle(getResources().getString(R.string.setup_error_title));
  alertBuilder.setMessage(getResources().getString(R.string.setup_error_text)).setCancelable(false).setPositiveButton(getResources().getString(R.string.setup_error_configure_button),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      startActivityForResult(new Intent(getAppContext(),ConfigurationWizard.class),CONFIGURE_LEAP);
    }
  }
).setNegativeButton(getResources().getString(R.string.setup_error_close_button),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      SharedPreferences.Editor prefsEdit=getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE).edit();
      prefsEdit.remove(ConfigHelper.PROVIDER_KEY).commit();
      finish();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Dialog shown when encountering a configuration error.  Such errors require reconfiguring LEAP or aborting the application.
 */
private void configErrorDialog(){
  AlertDialog.Builder alertBuilder=new AlertDialog.Builder(getAppContext());
  alertBuilder.setTitle(getResources().getString(R.string.setup_error_title));
  alertBuilder.setMessage(getResources().getString(R.string.setup_error_text)).setCancelable(false).setPositiveButton(getResources().getString(R.string.setup_error_configure_button),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      startActivityForResult(new Intent(getAppContext(),ConfigurationWizard.class),CONFIGURE_LEAP);
    }
  }
).setNegativeButton(getResources().getString(R.string.setup_error_close_button),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      SharedPreferences.Editor prefsEdit=getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE).edit();
      prefsEdit.remove(ConfigHelper.PROVIDER_KEY).commit();
      finish();
    }
  }
).show();
}