nus-yam/ex-repair huggingface dataset:
Program: 162474
Project: 162474
Buggy source:
private static boolean rmdir(final File file,Context context){
  if (file == null)   return false;
  if (!file.exists()) {
    return true;
  }
  if (!file.isDirectory()) {
    return false;
  }
  String[] fileList=file.list();
  if (fileList != null && fileList.length > 0) {
    rmdir1(file,context);
  }
  String[] fileList1=file.list();
  if (fileList1 != null && fileList1.length > 0) {
    return false;
  }
  if (file.delete()) {
    return true;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    DocumentFile document=getDocumentFile(file,true,context);
    return document.delete();
  }
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
    ContentResolver resolver=context.getContentResolver();
    ContentValues values=new ContentValues();
    values.put(MediaStore.MediaColumns.DATA,file.getAbsolutePath());
    resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);
    resolver.delete(MediaStore.Files.getContentUri("String_Node_Str"),MediaStore.MediaColumns.DATA + "String_Node_Str",new String[]{file.getAbsolutePath()});
  }
  return !file.exists();
}

Fixed version (ground truth):
/** 
 * Delete a folder.
 * @param file The folder name.
 * @return true if successful.
 */
private static boolean rmdir(@NonNull final File file,Context context){
  if (!file.exists())   return true;
  File[] files=file.listFiles();
  if (files != null && files.length > 0) {
    for (    File child : files) {
      rmdir(child,context);
    }
  }
  if (file.delete()) {
    return true;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    DocumentFile document=getDocumentFile(file,true,context);
    if (document != null && document.delete()) {
      return true;
    }
  }
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
    ContentResolver resolver=context.getContentResolver();
    ContentValues values=new ContentValues();
    values.put(MediaStore.MediaColumns.DATA,file.getAbsolutePath());
    resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);
    resolver.delete(MediaStore.Files.getContentUri("String_Node_Str"),MediaStore.MediaColumns.DATA + "String_Node_Str",new String[]{file.getAbsolutePath()});
  }
  return !file.exists();
}
Program: 162475
Project: 162475
Buggy source:
/** 
 * Delete a file. May be even on external SD card.
 * @param file the file to be deleted.
 * @return True if successfully deleted.
 */
static boolean deleteFile(@NonNull final File file,Context context){
  if (file == null)   return true;
  boolean fileDelete=deleteFilesInFolder(file,context);
  if (file.delete() || fileDelete)   return true;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && FileUtil.isOnExtSdCard(file,context)) {
    DocumentFile document=getDocumentFile(file,false,context);
    return document.delete();
  }
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
    ContentResolver resolver=context.getContentResolver();
    try {
      Uri uri=MediaStoreHack.getUriFromFile(file.getAbsolutePath(),context);
      resolver.delete(uri,null,null);
      return !file.exists();
    }
 catch (    Exception e) {
      Log.e(LOG,"String_Node_Str" + file.getAbsolutePath(),e);
      return false;
    }
  }
  return !file.exists();
}

Fixed version (ground truth):
/** 
 * Delete a file. May be even on external SD card.
 * @param file the file to be deleted.
 * @return True if successfully deleted.
 */
static boolean deleteFile(@NonNull final File file,Context context){
  if (file == null)   return true;
  boolean fileDelete=rmdir(file,context);
  if (file.delete() || fileDelete)   return true;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && FileUtil.isOnExtSdCard(file,context)) {
    DocumentFile document=getDocumentFile(file,false,context);
    return document.delete();
  }
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
    ContentResolver resolver=context.getContentResolver();
    try {
      Uri uri=MediaStoreHack.getUriFromFile(file.getAbsolutePath(),context);
      resolver.delete(uri,null,null);
      return !file.exists();
    }
 catch (    Exception e) {
      Log.e(LOG,"String_Node_Str" + file.getAbsolutePath(),e);
      return false;
    }
  }
  return !file.exists();
}
Program: 162476
Project: 162476
Buggy source:
/** 
 * Show dialog to rename a file
 * @param f the file to rename
 */
public void rename(final HybridFileParcelable f){
  MaterialDialog.Builder builder=new MaterialDialog.Builder(getActivity());
  String name=f.getName();
  builder.input("String_Node_Str",name,false,(materialDialog,charSequence) -> {
  }
);
  builder.theme(utilsProvider.getAppTheme().getMaterialDialogTheme());
  builder.title(getResources().getString(R.string.rename));
  builder.onNegative((dialog,which) -> dialog.cancel());
  builder.onPositive((dialog,which) -> {
    String name1=dialog.getInputEditText().getText().toString();
    if (f.isSmb()) {
      if (f.isDirectory() && !name1.endsWith("String_Node_Str"))       name1=name1 + "String_Node_Str";
    }
    getMainActivity().mainActivityHelper.rename(openMode,f.getPath(),CURRENT_PATH + "String_Node_Str" + name1,getActivity(),getMainActivity().isRootExplorer());
  }
);
  builder.positiveText(R.string.save);
  builder.negativeText(R.string.cancel);
  builder.positiveColor(accentColor).negativeColor(accentColor).widgetColor(accentColor);
  final MaterialDialog materialDialog=builder.build();
  materialDialog.show();
  Log.d(getClass().getSimpleName(),f.getNameString(getContext()));
  materialDialog.getInputEditText().post(() -> {
    if (!f.isDirectory()) {
      materialDialog.getInputEditText().setSelection(f.getNameString(getContext()).length());
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Show dialog to rename a file
 * @param f the file to rename
 */
public void rename(final HybridFileParcelable f){
  MaterialDialog.Builder builder=new MaterialDialog.Builder(getActivity());
  String name=f.getName();
  builder.input("String_Node_Str",name,false,(materialDialog,charSequence) -> {
  }
);
  builder.theme(utilsProvider.getAppTheme().getMaterialDialogTheme());
  builder.title(getResources().getString(R.string.rename));
  builder.onNegative((dialog,which) -> dialog.cancel());
  builder.onPositive((dialog,which) -> {
    String name1=dialog.getInputEditText().getText().toString();
    getMainActivity().mainActivityHelper.rename(openMode,f.getPath(),CURRENT_PATH + "String_Node_Str" + name1,getActivity(),getMainActivity().isRootExplorer());
  }
);
  builder.positiveText(R.string.save);
  builder.negativeText(R.string.cancel);
  builder.positiveColor(accentColor).negativeColor(accentColor).widgetColor(accentColor);
  final MaterialDialog materialDialog=builder.build();
  materialDialog.show();
  Log.d(getClass().getSimpleName(),f.getNameString(getContext()));
  materialDialog.getInputEditText().post(() -> {
    if (!f.isDirectory()) {
      materialDialog.getInputEditText().setSelection(f.getNameString(getContext()).length());
    }
  }
);
}
Program: 162477
Project: 162477
Buggy source:
private void checkUnsavedChanges(){
  if (mOriginal != null && mInput.isShown() && !mOriginal.equals(mInput.getText().toString())) {
    new MaterialDialog.Builder(this).title(R.string.unsavedchanges).content(R.string.unsavedchangesdesc).positiveText(R.string.yes).negativeText(R.string.no).positiveColor(getColorPreference().getColor(ColorUsage.ACCENT)).negativeColor(getColorPreference().getColor(ColorUsage.ACCENT)).callback(new MaterialDialog.ButtonCallback(){
      @Override public void onPositive(      MaterialDialog dialog){
        saveFile(mInput.getText().toString());
        finish();
      }
      @Override public void onNegative(      MaterialDialog dialog){
        finish();
      }
    }
).build().show();
  }
 else {
    finish();
  }
}

Fixed version (ground truth):
private void checkUnsavedChanges(){
  if (mOriginal != null && mInput.isShown() && !mOriginal.equals(mInput.getText().toString())) {
    new MaterialDialog.Builder(this).title(R.string.unsavedchanges).content(R.string.unsavedchangesdesc).positiveText(R.string.yes).negativeText(R.string.no).positiveColor(getColorPreference().getColor(ColorUsage.ACCENT)).negativeColor(getColorPreference().getColor(ColorUsage.ACCENT)).onPositive((dialog,which) -> {
      saveFile(mInput.getText().toString());
      finish();
    }
).onNegative((dialog,which) -> finish()).build().show();
  }
 else {
    finish();
  }
}
Program: 162478
Project: 162478
Buggy source:
/** 
 * Kill any connection that is still in place. Used by   {@link com.amaze.filemanager.activities.MainActivity}.
 * @see MainActivity#onDestroy()
 * @see MainActivity#exit()
 */
public void expungeAllConnections(){
  AppConfig.runInBackground(() -> {
    if (!mConnections.isEmpty()) {
      for (      SSHClient connection : mConnections.values()) {
        SshClientUtils.tryDisconnect(connection);
      }
      mConnections.clear();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Kill any connection that is still in place. Used by   {@link com.amaze.filemanager.activities.MainActivity}.
 * @see MainActivity#onDestroy()
 * @see MainActivity#exit()
 */
public void expungeAllConnections(){
  AppConfig.runInBackground(() -> {
    if (!connections.isEmpty()) {
      for (      SSHClient connection : connections.values()) {
        SshClientUtils.tryDisconnect(connection);
      }
      connections.clear();
    }
  }
);
}
Program: 162479
Project: 162479
Buggy source:
/** 
 * Obtain a   {@link SSHClient} connection from the underlying connection pool.Beneath it will return the connection if it exists; otherwise it will create a new one and put it into the connection pool.
 * @param url SSH connection URL, in the form of <code>ssh://&lt;username&gt;:&lt;password&gt;@&lt;host&gt;:&lt;port&gt;</code> or <code>ssh://&lt;username&gt;@&lt;host&gt;:&lt;port&gt;</code>
 * @return {@link SSHClient} connection, already opened and authenticated
 * @throws IOException IOExceptions that occur during connection setup
 */
public SSHClient getConnection(@NonNull String url) throws IOException {
  url=SshClientUtils.extractBaseUriFrom(url);
  SSHClient client=mConnections.get(url);
  if (client == null) {
    client=create(url);
    if (client != null)     mConnections.put(url,client);
  }
 else {
    if (!validate(client)) {
      Log.d(TAG,"String_Node_Str");
      expire(client);
      mConnections.remove(url);
      client=create(url);
      if (client != null)       mConnections.put(url,client);
    }
  }
  return client;
}

Fixed version (ground truth):
/** 
 * Obtain a   {@link SSHClient} connection from the underlying connection pool.Beneath it will return the connection if it exists; otherwise it will create a new one and put it into the connection pool.
 * @param url SSH connection URL, in the form of <code>ssh://&lt;username&gt;:&lt;password&gt;@&lt;host&gt;:&lt;port&gt;</code> or <code>ssh://&lt;username&gt;@&lt;host&gt;:&lt;port&gt;</code>
 * @return {@link SSHClient} connection, already opened and authenticated
 * @throws IOException IOExceptions that occur during connection setup
 */
public SSHClient getConnection(@NonNull String url) throws IOException {
  url=SshClientUtils.extractBaseUriFrom(url);
  SSHClient client=connections.get(url);
  if (client == null) {
    client=create(url);
    if (client != null)     connections.put(url,client);
  }
 else {
    if (!validate(client)) {
      Log.d(TAG,"String_Node_Str");
      expire(client);
      connections.remove(url);
      client=create(url);
      if (client != null)       connections.put(url,client);
    }
  }
  return client;
}
Program: 162480
Project: 162480
Buggy source:
private SshConnectionPool(){
  mConnections=new ConcurrentHashMap<String,SSHClient>();
}

Fixed version (ground truth):
private SshConnectionPool(){
  connections=new ConcurrentHashMap<String,SSHClient>();
}
Program: 162481
Project: 162481
Buggy source:
/** 
 * Use this to obtain SshConnectionPool instance singleton.
 * @return {@link SshConnectionPool} instance
 */
public static final SshConnectionPool getInstance(){
  if (sInstance == null)   sInstance=new SshConnectionPool();
  return sInstance;
}

Fixed version (ground truth):
/** 
 * Use this to obtain SshConnectionPool instance singleton.
 * @return {@link SshConnectionPool} instance
 */
public static final SshConnectionPool getInstance(){
  if (instance == null)   instance=new SshConnectionPool();
  return instance;
}
Program: 162482
Project: 162482
Buggy source:
public Response(String remotePath,net.schmizz.sshj.sftp.Response response) throws SFTPException, Buffer.BufferException {
  response.ensurePacketTypeIs(PacketType.EXTENDED_REPLY);
  if (!response.readStatusCode().equals(net.schmizz.sshj.sftp.Response.StatusCode.OK)) {
    throw new SFTPException("String_Node_Str" + response.readStatusCode());
  }
  mRemotePath=remotePath;
  mResponse=response;
  fileSystemBlockSize=(int)mResponse.readUInt32();
  fundamentalFileSystemBlockSize=(int)mResponse.readUInt64();
  fileSystemBlocks=mResponse.readUInt64();
  freeFileSystemBlocks=mResponse.readUInt64();
  availableFileSystemBlocks=mResponse.readUInt64();
  totalFileInodes=mResponse.readUInt64();
  freeFileInodes=mResponse.readUInt64();
  availableFileInodes=mResponse.readUInt64();
  fileSystemId=readUInt64FromBuffer(mResponse);
  fileSystemFlag=(int)mResponse.readUInt64();
  filenameMaxLength=(int)mResponse.readUInt64();
}

Fixed version (ground truth):
public Response(String remotePath,net.schmizz.sshj.sftp.Response response) throws SFTPException, Buffer.BufferException {
  response.ensurePacketTypeIs(PacketType.EXTENDED_REPLY);
  if (!response.readStatusCode().equals(net.schmizz.sshj.sftp.Response.StatusCode.OK)) {
    throw new SFTPException("String_Node_Str" + response.readStatusCode());
  }
  this.remotePath=remotePath;
  this.response=response;
  fileSystemBlockSize=(int)this.response.readUInt32();
  fundamentalFileSystemBlockSize=(int)this.response.readUInt64();
  fileSystemBlocks=this.response.readUInt64();
  freeFileSystemBlocks=this.response.readUInt64();
  availableFileSystemBlocks=this.response.readUInt64();
  totalFileInodes=this.response.readUInt64();
  freeFileInodes=this.response.readUInt64();
  availableFileInodes=this.response.readUInt64();
  fileSystemId=readUInt64FromBuffer(this.response);
  fileSystemFlag=(int)this.response.readUInt64();
  filenameMaxLength=(int)this.response.readUInt64();
}
Program: 162483
Project: 162483
Buggy source:
@Override public String toString(){
  return new StringBuilder().append("String_Node_Str").append(mRemotePath).append("String_Node_Str").append("String_Node_Str").append(fileSystemBlockSize).append(',').append("String_Node_Str").append(fundamentalFileSystemBlockSize).append(',').append("String_Node_Str").append(fileSystemBlocks).append(',').append("String_Node_Str").append(freeFileSystemBlocks).append(',').append("String_Node_Str").append(availableFileSystemBlocks).append(',').append("String_Node_Str").append(totalFileInodes).append(',').append("String_Node_Str").append(freeFileInodes).append(',').append("String_Node_Str").append(availableFileInodes).append(',').append("String_Node_Str").append(getFileSystemId()).append(',').append("String_Node_Str").append(fileSystemFlag).append(',').append("String_Node_Str").append(filenameMaxLength).toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return new StringBuilder().append("String_Node_Str").append(remotePath).append("String_Node_Str").append("String_Node_Str").append(fileSystemBlockSize).append(',').append("String_Node_Str").append(fundamentalFileSystemBlockSize).append(',').append("String_Node_Str").append(fileSystemBlocks).append(',').append("String_Node_Str").append(freeFileSystemBlocks).append(',').append("String_Node_Str").append(availableFileSystemBlocks).append(',').append("String_Node_Str").append(totalFileInodes).append(',').append("String_Node_Str").append(freeFileInodes).append(',').append("String_Node_Str").append(availableFileInodes).append(',').append("String_Node_Str").append(getFileSystemId()).append(',').append("String_Node_Str").append(fileSystemFlag).append(',').append("String_Node_Str").append(filenameMaxLength).toString();
}
Program: 162484
Project: 162484
Buggy source:
@Override protected void onPreExecute(){
  mProgressDialog=ProgressDialog.show(AppConfig.getInstance().getActivityContext(),"String_Node_Str",AppConfig.getInstance().getResources().getString(R.string.processing));
}

Fixed version (ground truth):
@Override protected void onPreExecute(){
  progressDialog=ProgressDialog.show(AppConfig.getInstance().getActivityContext(),"String_Node_Str",AppConfig.getInstance().getResources().getString(R.string.processing));
}
Program: 162485
Project: 162485
Buggy source:
@Override protected AsyncTaskResult<PublicKey> doInBackground(Void... voids){
  final AtomicReference<AsyncTaskResult<PublicKey>> holder=new AtomicReference<AsyncTaskResult<PublicKey>>();
  final CountDownLatch latch=new CountDownLatch(1);
  final SSHClient sshClient=new SSHClient(new CustomSshJConfig());
  sshClient.setConnectTimeout(SSH_CONNECT_TIMEOUT);
  sshClient.addHostKeyVerifier((hostname,port,key) -> {
    holder.set(new AsyncTaskResult<PublicKey>(key));
    latch.countDown();
    return true;
  }
);
  try {
    sshClient.connect(mHostname,mPort);
    latch.await();
  }
 catch (  IOException e) {
    e.printStackTrace();
    holder.set(new AsyncTaskResult<PublicKey>(e));
    latch.countDown();
  }
catch (  InterruptedException e) {
    e.printStackTrace();
    holder.set(new AsyncTaskResult<PublicKey>(e));
    latch.countDown();
  }
 finally {
    SshClientUtils.tryDisconnect(sshClient);
    return holder.get();
  }
}

Fixed version (ground truth):
@Override protected AsyncTaskResult<PublicKey> doInBackground(Void... voids){
  final AtomicReference<AsyncTaskResult<PublicKey>> holder=new AtomicReference<AsyncTaskResult<PublicKey>>();
  final CountDownLatch latch=new CountDownLatch(1);
  final SSHClient sshClient=new SSHClient(new CustomSshJConfig());
  sshClient.setConnectTimeout(SSH_CONNECT_TIMEOUT);
  sshClient.addHostKeyVerifier((hostname,port,key) -> {
    holder.set(new AsyncTaskResult<PublicKey>(key));
    latch.countDown();
    return true;
  }
);
  try {
    sshClient.connect(hostname,port);
    latch.await();
  }
 catch (  IOException e) {
    e.printStackTrace();
    holder.set(new AsyncTaskResult<PublicKey>(e));
    latch.countDown();
  }
catch (  InterruptedException e) {
    e.printStackTrace();
    holder.set(new AsyncTaskResult<PublicKey>(e));
    latch.countDown();
  }
 finally {
    SshClientUtils.tryDisconnect(sshClient);
    return holder.get();
  }
}
Program: 162486
Project: 162486
Buggy source:
@Override protected void onPostExecute(AsyncTaskResult<PublicKey> result){
  mProgressDialog.dismiss();
  if (result.exception != null) {
    if (SocketException.class.isAssignableFrom(result.exception.getClass()) || SocketTimeoutException.class.isAssignableFrom(result.exception.getClass())) {
      Toast.makeText(AppConfig.getInstance(),String.format(AppConfig.getInstance().getResources().getString(R.string.ssh_connect_failed),mHostname,mPort,result.exception.getLocalizedMessage()),Toast.LENGTH_LONG).show();
    }
  }
 else {
    mCallback.onResult(result);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(AsyncTaskResult<PublicKey> result){
  progressDialog.dismiss();
  if (result.exception != null) {
    if (SocketException.class.isAssignableFrom(result.exception.getClass()) || SocketTimeoutException.class.isAssignableFrom(result.exception.getClass())) {
      Toast.makeText(AppConfig.getInstance(),String.format(AppConfig.getInstance().getResources().getString(R.string.ssh_connect_failed),hostname,port,result.exception.getLocalizedMessage()),Toast.LENGTH_LONG).show();
    }
  }
 else {
    callback.onResult(result);
  }
}
Program: 162487
Project: 162487
Buggy source:
public GetSshHostFingerprintTask(@NonNull String hostname,int port,AsyncTaskResult.Callback<AsyncTaskResult<PublicKey>> callback){
  this.mHostname=hostname;
  this.mPort=port;
  this.mCallback=callback;
}

Fixed version (ground truth):
public GetSshHostFingerprintTask(@NonNull String hostname,int port,AsyncTaskResult.Callback<AsyncTaskResult<PublicKey>> callback){
  this.hostname=hostname;
  this.port=port;
  this.callback=callback;
}
Program: 162488
Project: 162488
Buggy source:
@Override protected AsyncTaskResult<KeyPair> doInBackground(Void... voids){
  AsyncTaskResult<KeyPair> retval=null;
  for (  Provider provider : Security.getProviders())   Log.d(TAG,"String_Node_Str" + provider.getName());
  try {
    for (    PemToKeyPairConverter converter : converters) {
      KeyPair keyPair=converter.convert(new String(mPemFile));
      if (keyPair != null) {
        retval=new AsyncTaskResult<KeyPair>(keyPair);
        break;
      }
    }
    if (retval == null)     throw new IOException("String_Node_Str");
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
    retval=new AsyncTaskResult<KeyPair>(e);
  }
  return retval;
}

Fixed version (ground truth):
@Override protected AsyncTaskResult<KeyPair> doInBackground(Void... voids){
  AsyncTaskResult<KeyPair> retval=null;
  for (  Provider provider : Security.getProviders())   Log.d(TAG,"String_Node_Str" + provider.getName());
  try {
    for (    PemToKeyPairConverter converter : converters) {
      KeyPair keyPair=converter.convert(new String(pemFile));
      if (keyPair != null) {
        retval=new AsyncTaskResult<KeyPair>(keyPair);
        break;
      }
    }
    if (retval == null)     throw new IOException("String_Node_Str");
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
    retval=new AsyncTaskResult<KeyPair>(e);
  }
  return retval;
}
Program: 162489
Project: 162489
Buggy source:
public PemToKeyPairTask(@NonNull byte[] pemContent,AsyncTaskResult.Callback<AsyncTaskResult<KeyPair>> callback,String keyPassphrase){
  this.mPemFile=pemContent;
  this.mCallback=callback;
  if (keyPassphrase == null)   mPasswordFinder=null;
 else   mPasswordFinder=new PasswordFinder(){
    @Override public char[] reqPassword(    Resource<?> resource){
      return keyPassphrase.toCharArray();
    }
    @Override public boolean shouldRetry(    Resource<?> resource){
      return false;
    }
  }
;
}

Fixed version (ground truth):
public PemToKeyPairTask(@NonNull byte[] pemContent,AsyncTaskResult.Callback<AsyncTaskResult<KeyPair>> callback,String keyPassphrase){
  this.pemFile=pemContent;
  this.callback=callback;
  if (keyPassphrase == null)   passwordFinder=null;
 else   passwordFinder=new PasswordFinder(){
    @Override public char[] reqPassword(    Resource<?> resource){
      return keyPassphrase.toCharArray();
    }
    @Override public boolean shouldRetry(    Resource<?> resource){
      return false;
    }
  }
;
}
Program: 162490
Project: 162490
Buggy source:
@Override protected void onPostExecute(AsyncTaskResult<KeyPair> result){
  if (result.exception != null) {
    MaterialDialog.Builder builder=new MaterialDialog.Builder(AppConfig.getInstance().getActivityContext());
    EditText textfield=new EditText(builder.getContext());
    textfield.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    builder.customView(textfield,false).title(R.string.ssh_key_prompt_passphrase).positiveText(R.string.ok).onPositive(((dialog,which) -> {
      new PemToKeyPairTask(mPemFile,mCallback,textfield.getText().toString()).execute();
      dialog.dismiss();
    }
)).negativeText(R.string.cancel).onNegative(((dialog,which) -> {
      dialog.dismiss();
      toastOnParseError(result);
    }
));
    builder.show();
  }
  if (mCallback != null) {
    mCallback.onResult(result);
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(AsyncTaskResult<KeyPair> result){
  if (result.exception != null) {
    MaterialDialog.Builder builder=new MaterialDialog.Builder(AppConfig.getInstance().getActivityContext());
    EditText textfield=new EditText(builder.getContext());
    textfield.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    builder.customView(textfield,false).title(R.string.ssh_key_prompt_passphrase).positiveText(R.string.ok).onPositive(((dialog,which) -> {
      new PemToKeyPairTask(pemFile,callback,textfield.getText().toString()).execute();
      dialog.dismiss();
    }
)).negativeText(R.string.cancel).onNegative(((dialog,which) -> {
      dialog.dismiss();
      toastOnParseError(result);
    }
));
    builder.show();
  }
  if (callback != null) {
    callback.onResult(result);
  }
}
Program: 162491
Project: 162491
Buggy source:
@Override public KeyPair convert(String source){
  PuTTYKeyFile converter=new PuTTYKeyFile();
  converter.init(new StringReader(source),mPasswordFinder);
  try {
    return new KeyPair(converter.getPublic(),converter.getPrivate());
  }
 catch (  Exception ignored) {
    ignored.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
@Override public KeyPair convert(String source){
  PuTTYKeyFile converter=new PuTTYKeyFile();
  converter.init(new StringReader(source),passwordFinder);
  try {
    return new KeyPair(converter.getPublic(),converter.getPrivate());
  }
 catch (  Exception ignored) {
    ignored.printStackTrace();
    return null;
  }
}
Program: 162492
Project: 162492
Buggy source:
@Override public PrivateKey getPrivate() throws IOException {
  return mPrivateKey.getPrivate();
}

Fixed version (ground truth):
@Override public PrivateKey getPrivate() throws IOException {
  return privateKey.getPrivate();
}
Program: 162493
Project: 162493
Buggy source:
@Override protected AsyncTaskResult<SSHClient> doInBackground(Void... voids){
  final SSHClient sshClient=new SSHClient(new CustomSshJConfig());
  sshClient.addHostKeyVerifier(mHostKey);
  sshClient.setConnectTimeout(SSH_CONNECT_TIMEOUT);
  try {
    sshClient.connect(mHostname,mPort);
    if (mPassword != null && !"String_Node_Str".equals(mPassword)) {
      sshClient.authPassword(mUsername,mPassword);
      return new AsyncTaskResult<SSHClient>(sshClient);
    }
 else {
      sshClient.authPublickey(mUsername,new KeyProvider(){
        @Override public PrivateKey getPrivate() throws IOException {
          return mPrivateKey.getPrivate();
        }
        @Override public PublicKey getPublic() throws IOException {
          return mPrivateKey.getPublic();
        }
        @Override public KeyType getType() throws IOException {
          return KeyType.fromKey(getPublic());
        }
      }
);
      return new AsyncTaskResult<SSHClient>(sshClient);
    }
  }
 catch (  UserAuthException e) {
    e.printStackTrace();
    return new AsyncTaskResult<SSHClient>(e);
  }
catch (  TransportException e) {
    e.printStackTrace();
    return new AsyncTaskResult<SSHClient>(e);
  }
catch (  IOException e) {
    e.printStackTrace();
    return new AsyncTaskResult<SSHClient>(e);
  }
}

Fixed version (ground truth):
@Override protected AsyncTaskResult<SSHClient> doInBackground(Void... voids){
  final SSHClient sshClient=new SSHClient(new CustomSshJConfig());
  sshClient.addHostKeyVerifier(hostKey);
  sshClient.setConnectTimeout(SSH_CONNECT_TIMEOUT);
  try {
    sshClient.connect(hostname,port);
    if (password != null && !"String_Node_Str".equals(password)) {
      sshClient.authPassword(username,password);
      return new AsyncTaskResult<SSHClient>(sshClient);
    }
 else {
      sshClient.authPublickey(username,new KeyProvider(){
        @Override public PrivateKey getPrivate() throws IOException {
          return privateKey.getPrivate();
        }
        @Override public PublicKey getPublic() throws IOException {
          return privateKey.getPublic();
        }
        @Override public KeyType getType() throws IOException {
          return KeyType.fromKey(getPublic());
        }
      }
);
      return new AsyncTaskResult<SSHClient>(sshClient);
    }
  }
 catch (  UserAuthException e) {
    e.printStackTrace();
    return new AsyncTaskResult<SSHClient>(e);
  }
catch (  TransportException e) {
    e.printStackTrace();
    return new AsyncTaskResult<SSHClient>(e);
  }
catch (  IOException e) {
    e.printStackTrace();
    return new AsyncTaskResult<SSHClient>(e);
  }
}
Program: 162494
Project: 162494
Buggy source:
/** 
 * Constructor.
 * @param hostname hostname, required
 * @param port port, must be unsigned integer
 * @param hostKey SSH host fingerprint, required
 * @param username login username, required
 * @param password login password, required if using password authentication
 * @param privateKey login {@link KeyPair}, required if using key-based authentication
 */
public SshAuthenticationTask(@NonNull String hostname,@NonNull int port,@NonNull String hostKey,@NonNull String username,String password,KeyPair privateKey){
  this.mHostname=hostname;
  this.mPort=port;
  this.mHostKey=hostKey;
  this.mUsername=username;
  this.mPassword=password;
  this.mPrivateKey=privateKey;
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param hostname hostname, required
 * @param port port, must be unsigned integer
 * @param hostKey SSH host fingerprint, required
 * @param username login username, required
 * @param password login password, required if using password authentication
 * @param privateKey login {@link KeyPair}, required if using key-based authentication
 */
public SshAuthenticationTask(@NonNull String hostname,@NonNull int port,@NonNull String hostKey,@NonNull String username,String password,KeyPair privateKey){
  this.hostname=hostname;
  this.port=port;
  this.hostKey=hostKey;
  this.username=username;
  this.password=password;
  this.privateKey=privateKey;
}
Program: 162496
Project: 162496
Buggy source:
@Override public PublicKey getPublic() throws IOException {
  return mPrivateKey.getPublic();
}

Fixed version (ground truth):
@Override public PublicKey getPublic() throws IOException {
  return privateKey.getPublic();
}
Program: 162498
Project: 162498
Buggy source:
@Override public boolean onPreferenceClick(final Preference preference){
switch (preference.getKey()) {
case KEY_COLOREDNAV:
    activity.invalidateNavBar();
  break;
case PreferencesConstants.PREFERENCE_SKIN:
case PreferencesConstants.PREFERENCE_SKIN_TWO:
case PreferencesConstants.PREFERENCE_ACCENT:
case PreferencesConstants.PREFERENCE_ICON_SKIN:
final ColorUsage usage=ColorUsage.fromString(preference.getKey());
if (usage != null) {
ColorAdapter adapter=new ColorAdapter(getActivity(),ColorPreference.availableColors,usage);
GridView v=(GridView)getActivity().getLayoutInflater().inflate(R.layout.dialog_grid,null);
v.setAdapter(adapter);
v.setOnItemClickListener(adapter);
int fab_skin=activity.getColorPreference().getColor(ColorUsage.ACCENT);
dialog=new MaterialDialog.Builder(getActivity()).positiveText(R.string.cancel).title(R.string.choose_color).theme(activity.getAppTheme().getMaterialDialogTheme()).autoDismiss(true).positiveColor(fab_skin).neutralColor(fab_skin).neutralText(R.string.defualt).callback(new MaterialDialog.ButtonCallback(){
  @Override public void onNeutral(  MaterialDialog dialog){
    super.onNeutral(dialog);
    if (activity != null)     activity.setRestartActivity();
    activity.getColorPreference().setRes(usage,usage.getDefaultColor()).saveToPreferences(sharedPref);
    invalidateEverything();
  }
}
).customView(v,false).build();
adapter.setDialog(dialog);
dialog.show();
}
return false;
case "String_Node_Str":
switchSections();
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onPreferenceClick(final Preference preference){
switch (preference.getKey()) {
case KEY_COLOREDNAV:
    activity.invalidateNavBar();
  break;
case PreferencesConstants.PREFERENCE_SKIN:
case PreferencesConstants.PREFERENCE_SKIN_TWO:
case PreferencesConstants.PREFERENCE_ACCENT:
case PreferencesConstants.PREFERENCE_ICON_SKIN:
final ColorUsage usage=ColorUsage.fromString(preference.getKey());
if (usage != null) {
ColorAdapter adapter=new ColorAdapter(getActivity(),ColorPreference.getUniqueAvailableColors(getActivity()),usage);
GridView v=(GridView)getActivity().getLayoutInflater().inflate(R.layout.dialog_grid,null);
v.setAdapter(adapter);
v.setOnItemClickListener(adapter);
int fab_skin=activity.getColorPreference().getColor(ColorUsage.ACCENT);
dialog=new MaterialDialog.Builder(getActivity()).positiveText(R.string.cancel).title(R.string.choose_color).theme(activity.getAppTheme().getMaterialDialogTheme()).autoDismiss(true).positiveColor(fab_skin).neutralColor(fab_skin).neutralText(R.string.defualt).callback(new MaterialDialog.ButtonCallback(){
  @Override public void onNeutral(  MaterialDialog dialog){
    super.onNeutral(dialog);
    if (activity != null)     activity.setRestartActivity();
    activity.getColorPreference().setRes(usage,usage.getDefaultColor()).saveToPreferences(sharedPref);
    invalidateEverything();
  }
}
).customView(v,false).build();
adapter.setDialog(dialog);
dialog.show();
}
return false;
case "String_Node_Str":
switchSections();
return true;
}
return false;
}
Program: 162500
Project: 162500
Buggy source:
public boolean onActionItemClicked(ActionMode mode,MenuItem item){
switch (item.getItemId()) {
case R.id.all:
    compressedExplorerAdapter.toggleChecked(true);
  mode.invalidate();
return true;
case R.id.ex:
Toast.makeText(getActivity(),getResources().getString(R.string.extracting),Toast.LENGTH_SHORT).show();
String[] dirs=new String[compressedExplorerAdapter.getCheckedItemPositions().size()];
for (int i=0; i < dirs.length; i++) {
dirs[i]=elements.get(compressedExplorerAdapter.getCheckedItemPositions().get(i)).name;
}
compressedInterface.decompress(null,dirs);
mode.finish();
return true;
}
return false;
}

Fixed version (ground truth):
public boolean onActionItemClicked(ActionMode mode,MenuItem item){
switch (item.getItemId()) {
case R.id.all:
    ArrayList<Integer> positions=compressedExplorerAdapter.getCheckedItemPositions();
  boolean shouldDeselectAll=positions.size() != folder + file;
compressedExplorerAdapter.toggleChecked(shouldDeselectAll);
mode.invalidate();
item.setTitle(shouldDeselectAll ? R.string.deselect_all : R.string.selectall);
if (!shouldDeselectAll) {
selection=false;
mActionMode.finish();
mActionMode=null;
}
return true;
case R.id.ex:
Toast.makeText(getActivity(),getResources().getString(R.string.extracting),Toast.LENGTH_SHORT).show();
String[] dirs=new String[compressedExplorerAdapter.getCheckedItemPositions().size()];
for (int i=0; i < dirs.length; i++) {
dirs[i]=elements.get(compressedExplorerAdapter.getCheckedItemPositions().get(i)).name;
}
compressedInterface.decompress(null,dirs);
mode.finish();
return true;
}
return false;
}
Program: 162501
Project: 162501
Buggy source:
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
  ArrayList<Integer> positions=compressedExplorerAdapter.getCheckedItemPositions();
  ((TextView)v.findViewById(R.id.item_count)).setText(positions.size() + "String_Node_Str");
  return false;
}

Fixed version (ground truth):
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
  ArrayList<Integer> positions=compressedExplorerAdapter.getCheckedItemPositions();
  ((TextView)v.findViewById(R.id.item_count)).setText(positions.size() + "String_Node_Str");
  menu.findItem(R.id.all).setTitle(positions.size() == folder + file ? R.string.deselect_all : R.string.selectall);
  return false;
}
Program: 162503
Project: 162503
Buggy source:
public boolean onActionItemClicked(ActionMode mode,MenuItem item){
switch (item.getItemId()) {
case R.id.all:
    compressedExplorerAdapter.toggleChecked(true);
  mode.invalidate();
return true;
case R.id.ex:
Toast.makeText(getActivity(),getResources().getString(R.string.extracting),Toast.LENGTH_SHORT).show();
String[] dirs=new String[compressedExplorerAdapter.getCheckedItemPositions().size()];
for (int i=0; i < dirs.length; i++) {
dirs[i]=elements.get(compressedExplorerAdapter.getCheckedItemPositions().get(i)).name;
}
compressedInterface.decompress(null,dirs);
mode.finish();
return true;
}
return false;
}

Fixed version (ground truth):
public boolean onActionItemClicked(ActionMode mode,MenuItem item){
switch (item.getItemId()) {
case R.id.all:
    ArrayList<Integer> positions=compressedExplorerAdapter.getCheckedItemPositions();
  boolean shouldDeselectAll=positions.size() != folder + file;
compressedExplorerAdapter.toggleChecked(shouldDeselectAll);
mode.invalidate();
item.setTitle(shouldDeselectAll ? R.string.deselect_all : R.string.selectall);
if (!shouldDeselectAll) {
selection=false;
mActionMode.finish();
mActionMode=null;
}
return true;
case R.id.ex:
Toast.makeText(getActivity(),getResources().getString(R.string.extracting),Toast.LENGTH_SHORT).show();
String[] dirs=new String[compressedExplorerAdapter.getCheckedItemPositions().size()];
for (int i=0; i < dirs.length; i++) {
dirs[i]=elements.get(compressedExplorerAdapter.getCheckedItemPositions().get(i)).name;
}
compressedInterface.decompress(null,dirs);
mode.finish();
return true;
}
return false;
}
Program: 162504
Project: 162504
Buggy source:
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
  ArrayList<Integer> positions=compressedExplorerAdapter.getCheckedItemPositions();
  ((TextView)v.findViewById(R.id.item_count)).setText(positions.size() + "String_Node_Str");
  return false;
}

Fixed version (ground truth):
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
  ArrayList<Integer> positions=compressedExplorerAdapter.getCheckedItemPositions();
  ((TextView)v.findViewById(R.id.item_count)).setText(positions.size() + "String_Node_Str");
  menu.findItem(R.id.all).setTitle(positions.size() == folder + file ? R.string.deselect_all : R.string.selectall);
  return false;
}
Program: 162507
Project: 162507
Buggy source:
@Override public void onBackPressed(){
  if (currentFragment instanceof ColorPref) {
    if (((ColorPref)currentFragment).onBackPressed())     return;
  }
  if (selectedItem != START_PREFERENCE && changed) {
    restartActivity(this);
  }
 else   if (selectedItem != START_PREFERENCE) {
    selectItem(START_PREFERENCE);
  }
 else {
    Intent in=new Intent(PreferencesActivity.this,MainActivity.class);
    in.setAction(Intent.ACTION_MAIN);
    in.setAction(Intent.CATEGORY_LAUNCHER);
    this.startActivity(in);
    this.finish();
  }
}

Fixed version (ground truth):
@Override public void onBackPressed(){
  if (currentFragment instanceof ColorPref) {
    if (((ColorPref)currentFragment).onBackPressed())     return;
  }
  if (selectedItem != START_PREFERENCE && restartActivity) {
    restartActivity(this);
  }
 else   if (selectedItem != START_PREFERENCE) {
    selectItem(START_PREFERENCE);
  }
 else {
    Intent in=new Intent(PreferencesActivity.this,MainActivity.class);
    in.setAction(Intent.ACTION_MAIN);
    in.setAction(Intent.CATEGORY_LAUNCHER);
    this.startActivity(in);
    this.finish();
  }
}
Program: 162508
Project: 162508
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    if (currentFragment.onOptionsItemSelected(item))     return true;
  if (selectedItem != START_PREFERENCE && changed) {
    restartActivity(this);
  }
 else   if (selectedItem != START_PREFERENCE) {
    selectItem(START_PREFERENCE);
  }
 else {
    Intent in=new Intent(PreferencesActivity.this,MainActivity.class);
    in.setAction(Intent.ACTION_MAIN);
    in.setAction(Intent.CATEGORY_LAUNCHER);
    final int enter_anim=android.R.anim.fade_in;
    final int exit_anim=android.R.anim.fade_out;
    Activity activity=this;
    activity.overridePendingTransition(enter_anim,exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim,exit_anim);
    activity.startActivity(in);
  }
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    if (currentFragment.onOptionsItemSelected(item))     return true;
  if (selectedItem != START_PREFERENCE && restartActivity) {
    restartActivity(this);
  }
 else   if (selectedItem != START_PREFERENCE) {
    selectItem(START_PREFERENCE);
  }
 else {
    Intent in=new Intent(PreferencesActivity.this,MainActivity.class);
    in.setAction(Intent.ACTION_MAIN);
    in.setAction(Intent.CATEGORY_LAUNCHER);
    final int enter_anim=android.R.anim.fade_in;
    final int exit_anim=android.R.anim.fade_out;
    Activity activity=this;
    activity.overridePendingTransition(enter_anim,exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim,exit_anim);
    activity.startActivity(in);
  }
return true;
}
return false;
}
Program: 162509
Project: 162509
Buggy source:
private void loadSection0(){
  if (((PreferencesActivity)getActivity()).getChanged()) {
    ((PreferencesActivity)getActivity()).restartActivity(getActivity());
  }
  addPreferencesFromResource(R.xml.color_prefs);
  if (Build.VERSION.SDK_INT >= 21) {
    findPreference(KEY_COLOREDNAV).setEnabled(true);
  }
}

Fixed version (ground truth):
private void loadSection0(){
  if (((PreferencesActivity)getActivity()).getRestartActivity()) {
    ((PreferencesActivity)getActivity()).restartActivity(getActivity());
  }
  addPreferencesFromResource(R.xml.color_prefs);
  if (Build.VERSION.SDK_INT >= 21) {
    findPreference(KEY_COLOREDNAV).setEnabled(true);
  }
}
Program: 162510
Project: 162510
Buggy source:
@Override public boolean onPreferenceClick(final Preference preference){
switch (preference.getKey()) {
case KEY_COLOREDNAV:
    activity.invalidateNavBar();
  break;
case PreferencesConstants.PREFERENCE_SKIN:
case PreferencesConstants.PREFERENCE_SKIN_TWO:
case PreferencesConstants.PREFERENCE_ACCENT:
case PreferencesConstants.PREFERENCE_ICON_SKIN:
final ColorUsage usage=ColorUsage.fromString(preference.getKey());
if (usage != null) {
ColorAdapter adapter=new ColorAdapter(getActivity(),ColorPreference.availableColors,usage);
GridView v=(GridView)getActivity().getLayoutInflater().inflate(R.layout.dialog_grid,null);
v.setAdapter(adapter);
v.setOnItemClickListener(adapter);
int fab_skin=activity.getColorPreference().getColor(ColorUsage.ACCENT);
dialog=new MaterialDialog.Builder(getActivity()).positiveText(R.string.cancel).title(R.string.choose_color).theme(activity.getAppTheme().getMaterialDialogTheme()).autoDismiss(true).positiveColor(fab_skin).neutralColor(fab_skin).neutralText(R.string.defualt).callback(new MaterialDialog.ButtonCallback(){
  @Override public void onNeutral(  MaterialDialog dialog){
    super.onNeutral(dialog);
    if (activity != null)     activity.setChanged();
    activity.getColorPreference().setRes(usage,usage.getDefaultColor()).saveToPreferences(sharedPref);
    invalidateEverything();
  }
}
).customView(v,false).build();
adapter.setDialog(dialog);
dialog.show();
}
return false;
case "String_Node_Str":
switchSections();
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onPreferenceClick(final Preference preference){
switch (preference.getKey()) {
case KEY_COLOREDNAV:
    activity.invalidateNavBar();
  break;
case PreferencesConstants.PREFERENCE_SKIN:
case PreferencesConstants.PREFERENCE_SKIN_TWO:
case PreferencesConstants.PREFERENCE_ACCENT:
case PreferencesConstants.PREFERENCE_ICON_SKIN:
final ColorUsage usage=ColorUsage.fromString(preference.getKey());
if (usage != null) {
ColorAdapter adapter=new ColorAdapter(getActivity(),ColorPreference.availableColors,usage);
GridView v=(GridView)getActivity().getLayoutInflater().inflate(R.layout.dialog_grid,null);
v.setAdapter(adapter);
v.setOnItemClickListener(adapter);
int fab_skin=activity.getColorPreference().getColor(ColorUsage.ACCENT);
dialog=new MaterialDialog.Builder(getActivity()).positiveText(R.string.cancel).title(R.string.choose_color).theme(activity.getAppTheme().getMaterialDialogTheme()).autoDismiss(true).positiveColor(fab_skin).neutralColor(fab_skin).neutralText(R.string.defualt).callback(new MaterialDialog.ButtonCallback(){
  @Override public void onNeutral(  MaterialDialog dialog){
    super.onNeutral(dialog);
    if (activity != null)     activity.setRestartActivity();
    activity.getColorPreference().setRes(usage,usage.getDefaultColor()).saveToPreferences(sharedPref);
    invalidateEverything();
  }
}
).customView(v,false).build();
adapter.setDialog(dialog);
dialog.show();
}
return false;
case "String_Node_Str":
switchSections();
return true;
}
return false;
}
Program: 162511
Project: 162511
Buggy source:
private void loadSection1(){
  addPreferencesFromResource(R.xml.conficolor_prefs);
  ColorPickerDialog selectedColors=(ColorPickerDialog)findPreference(KEY_PRESELECTED_CONFIGS);
  invalidateColorPreference(selectedColors);
  selectedColors.setColorPreference(activity.getColorPreference(),activity.getAppTheme());
  selectedColors.setListener(() -> {
    if (activity != null)     activity.setChanged();
    checkCustomization();
    invalidateEverything();
    int colorPickerPref=sharedPref.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG,ColorPickerDialog.NO_DATA);
    if (colorPickerPref == ColorPickerDialog.RANDOM_INDEX) {
      Toast.makeText(getActivity(),R.string.setRandom,Toast.LENGTH_LONG).show();
    }
  }
);
  checkCustomization();
}

Fixed version (ground truth):
private void loadSection1(){
  addPreferencesFromResource(R.xml.conficolor_prefs);
  ColorPickerDialog selectedColors=(ColorPickerDialog)findPreference(KEY_PRESELECTED_CONFIGS);
  invalidateColorPreference(selectedColors);
  selectedColors.setColorPreference(activity.getColorPreference(),activity.getAppTheme());
  selectedColors.setListener(() -> {
    if (activity != null)     activity.setRestartActivity();
    checkCustomization();
    invalidateEverything();
    int colorPickerPref=sharedPref.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG,ColorPickerDialog.NO_DATA);
    if (colorPickerPref == ColorPickerDialog.RANDOM_INDEX) {
      Toast.makeText(getActivity(),R.string.setRandom,Toast.LENGTH_LONG).show();
    }
  }
);
  checkCustomization();
}
Program: 162512
Project: 162512
Buggy source:
@Override public void onNeutral(MaterialDialog dialog){
  super.onNeutral(dialog);
  if (activity != null)   activity.setChanged();
  activity.getColorPreference().setRes(usage,usage.getDefaultColor()).saveToPreferences(sharedPref);
  invalidateEverything();
}

Fixed version (ground truth):
@Override public void onNeutral(MaterialDialog dialog){
  super.onNeutral(dialog);
  if (activity != null)   activity.setRestartActivity();
  activity.getColorPreference().setRes(usage,usage.getDefaultColor()).saveToPreferences(sharedPref);
  invalidateEverything();
}
Program: 162513
Project: 162513
Buggy source:
@Override public boolean onPreferenceClick(final Preference preference){
  if (sharedPrefs != null)   activity.setChanged();
  if (preference instanceof PathSwitchPreference) {
    PathSwitchPreference p=(PathSwitchPreference)preference;
switch (p.getLastItemClicked()) {
case PathSwitchPreference.EDIT:
      loadEditDialog((PathSwitchPreference)preference);
    break;
case PathSwitchPreference.DELETE:
  loadDeleteDialog((PathSwitchPreference)preference);
break;
default :
break;
}
}
 else if (preference.getKey().equals(PreferencesConstants.PREFERENCE_SHORTCUT)) {
if (getPreferenceScreen().getPreferenceCount() >= findPreference(PreferencesConstants.PREFERENCE_SHORTCUT).getOrder()) findPreference(PreferencesConstants.PREFERENCE_SHORTCUT).setOrder(getPreferenceScreen().getPreferenceCount() + 10);
loadCreateDialog();
}
return false;
}

Fixed version (ground truth):
@Override public boolean onPreferenceClick(final Preference preference){
  if (preference instanceof PathSwitchPreference) {
    PathSwitchPreference p=(PathSwitchPreference)preference;
switch (p.getLastItemClicked()) {
case PathSwitchPreference.EDIT:
      loadEditDialog((PathSwitchPreference)preference);
    break;
case PathSwitchPreference.DELETE:
  loadDeleteDialog((PathSwitchPreference)preference);
break;
default :
break;
}
}
 else if (preference.getKey().equals(PreferencesConstants.PREFERENCE_SHORTCUT)) {
if (getPreferenceScreen().getPreferenceCount() >= findPreference(PreferencesConstants.PREFERENCE_SHORTCUT).getOrder()) findPreference(PreferencesConstants.PREFERENCE_SHORTCUT).setOrder(getPreferenceScreen().getPreferenceCount() + 10);
loadCreateDialog();
}
return false;
}