nus-yam/ex-repair huggingface dataset:
Program: 50798
Project: 50798
Buggy source:
Record nextOwnedRecord(long recordId,int blockId){
  Record rec=null;
  while (rec == null && recordId <= maxId) {
    rec=getRecordById(recordId);
    if (rec != null) {
      if (rec.blockId == blockId) {
        if (rec.owner.equals(thisAddress)) {
          return rec;
        }
      }
    }
    rec=null;
    recordId++;
  }
  return rec;
}

Fixed version (ground truth):
Record nextOwnedRecord(String name,long recordId,int blockId){
  Record rec=null;
  while (rec == null && recordId <= maxId) {
    rec=getRecordById(recordId);
    if (rec != null) {
      if (name != null && name.equals(rec.name)) {
        if (rec.blockId == blockId) {
          if (rec.owner.equals(thisAddress)) {
            return rec;
          }
        }
      }
    }
    rec=null;
    recordId++;
  }
  return rec;
}
Program: 50799
Project: 50799
Buggy source:
public Record read(Request req){
  return nextOwnedRecord(req.recordId,req.blockId);
}

Fixed version (ground truth):
public Record read(Request req){
  return nextOwnedRecord(req.name,req.recordId,req.blockId);
}
Program: 50800
Project: 50800
Buggy source:
void handleSize(Invocation inv){
  CMap cmap=getMap(inv.name);
  inv.longValue=cmap.size();
  sendResponse(inv);
}

Fixed version (ground truth):
void handleSize(Invocation inv){
  if (migrating()) {
    inv.responseType=RESPONSE_REDO;
  }
 else {
    CMap cmap=getMap(inv.name);
    inv.longValue=cmap.size();
  }
  sendResponse(inv);
}
Program: 50801
Project: 50801
Buggy source:
public void writeObject(BufferProvider bufferProvider,Object obj) throws Exception {
  bbos.setBufferProvider(bufferProvider);
  bbos.reset();
  if (obj instanceof byte[]) {
    bbos.write((byte)40);
    byte[] bytes=(byte[])obj;
    bbos.writeInt(bytes.length);
    bbos.write((byte[])obj);
  }
 else   if (obj instanceof Long) {
    bbos.write((byte)41);
    bbos.writeLong(((Long)obj).longValue());
  }
 else   if (obj instanceof Integer) {
    bbos.write((byte)42);
    bbos.writeInt(((Integer)obj).intValue());
  }
 else   if (obj instanceof DataSerializable) {
    bbos.write((byte)45);
    bbos.writeUTF(obj.getClass().getName());
    ((DataSerializable)obj).writeData(bbos);
    bbos.writeInt(STREAM_END);
  }
 else   if (obj instanceof String) {
    bbos.write((byte)46);
    String str=(String)obj;
    bbos.writeUTF(str);
  }
 else {
    bbos.write((byte)66);
    ObjectOutputStream os=new ObjectOutputStream(bbos);
    os.writeObject(obj);
  }
  bbos.flush();
}

Fixed version (ground truth):
public void writeObject(BufferProvider bufferProvider,Object obj) throws Exception {
  bbos.setBufferProvider(bufferProvider);
  bbos.reset();
  if (obj instanceof byte[]) {
    bbos.write((byte)40);
    byte[] bytes=(byte[])obj;
    bbos.writeInt(bytes.length);
    bbos.write((byte[])obj);
  }
 else   if (obj instanceof Long) {
    bbos.write((byte)41);
    bbos.writeLong(((Long)obj).longValue());
  }
 else   if (obj instanceof Integer) {
    bbos.write((byte)42);
    bbos.writeInt(((Integer)obj).intValue());
  }
 else   if (obj instanceof DataSerializable) {
    bbos.write((byte)45);
    bbos.writeUTF(obj.getClass().getName());
    ((DataSerializable)obj).writeData(bbos);
    bbos.writeInt(STREAM_END);
  }
 else   if (obj instanceof String) {
    bbos.write((byte)46);
    String str=(String)obj;
    bbos.writeUTF(str);
  }
 else {
    bbos.write((byte)66);
    ObjectOutputStream os=new ObjectOutputStream(bbos);
    os.writeUnshared(obj);
  }
  bbos.flush();
}
Program: 50802
Project: 50802
Buggy source:
public Object readObject(BufferProvider bufferProvider){
  try {
    bbis.setBufferProvider(bufferProvider);
    bbis.reset();
    Object result=null;
    byte type=(byte)bbis.read();
    if (type == 40) {
      int size=bbis.readInt();
      byte[] bytes=new byte[size];
      bbis.read(bytes);
      result=bytes;
    }
 else     if (type == 41) {
      result=Long.valueOf(bbis.readLong());
    }
 else     if (type == 42) {
      result=Integer.valueOf(bbis.readInt());
    }
 else     if (type == 66) {
      ObjectInputStream in=new ObjectInputStream(bbis);
      result=in.readUnshared();
    }
 else     if (type == 45) {
      String className=bbis.readUTF();
      DataSerializable ds=(DataSerializable)Class.forName(className).newInstance();
      ds.readData(bbis);
      if (bbis.readInt() != STREAM_END)       throw new RuntimeException("String_Node_Str");
      result=ds;
    }
 else     if (type == 46) {
      result=bbis.readUTF();
    }
 else {
      throw new RuntimeException("String_Node_Str" + type);
    }
    return result;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
public Object readObject(BufferProvider bufferProvider){
  try {
    bbis.setBufferProvider(bufferProvider);
    bbis.reset();
    Object result=null;
    byte type=(byte)bbis.read();
    if (type == 40) {
      int size=bbis.readInt();
      byte[] bytes=new byte[size];
      bbis.read(bytes);
      result=bytes;
    }
 else     if (type == 41) {
      result=Long.valueOf(bbis.readLong());
    }
 else     if (type == 42) {
      result=Integer.valueOf(bbis.readInt());
    }
 else     if (type == 45) {
      String className=bbis.readUTF();
      DataSerializable ds=(DataSerializable)Class.forName(className).newInstance();
      ds.readData(bbis);
      if (bbis.readInt() != STREAM_END)       throw new RuntimeException("String_Node_Str");
      result=ds;
    }
 else     if (type == 46) {
      result=bbis.readUTF();
    }
 else     if (type == 66) {
      ObjectInputStream in=new ObjectInputStream(bbis);
      result=in.readUnshared();
    }
 else {
      throw new RuntimeException("String_Node_Str" + type);
    }
    return result;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}
Program: 50803
Project: 50803
Buggy source:
public boolean executeProcess(Address address,AbstractRemotelyProcessable arp){
  this.arp=arp;
  super.target=address;
  return booleanCall(OP_REMOTELY_PROCESS_AND_RESPONSE,"String_Node_Str",null,arp,0,-1,-1);
}

Fixed version (ground truth):
public boolean executeProcess(Address address,AbstractRemotelyProcessable arp){
  this.arp=arp;
  super.target=address;
  return booleanCall(OP_REMOTELY_PROCESS_AND_RESPOND,"String_Node_Str",null,arp,0,-1,-1);
}
Program: 50805
Project: 50805
Buggy source:
public void invoke(){
  ClusterService.get().enqueueAndReturn(DistributedExecutorAction.this);
}

Fixed version (ground truth):
public void invoke(){
  enqueueAndReturn(DistributedExecutorAction.this);
}
Program: 50806
Project: 50806
Buggy source:
static Object createProxy(String name){
  Object proxy=proxies.get(name);
  if (proxy == null) {
    if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new QProxy(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new TopicProxy(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new CProxy(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        byte mapType=BaseManager.getMapType(name);
        CProxy mapProxy=new CProxy(name);
        if (mapType == MAP_TYPE_SET) {
          proxy=new SetProxy(mapProxy);
        }
 else         if (mapType == MAP_TYPE_LIST) {
          proxy=new ListProxy(mapProxy);
        }
 else {
          proxy=mapProxy;
        }
        proxies.put(name,proxy);
      }
    }
  }
  return proxy;
}

Fixed version (ground truth):
static Object createProxy(String name){
  Object proxy=proxies.get(name);
  if (proxy == null) {
    if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new QProxy(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new TopicProxy(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        proxy=new MProxy(name);
        proxies.put(name,proxy);
      }
    }
 else     if (name.startsWith("String_Node_Str")) {
      proxy=proxies.get(name);
      if (proxy == null) {
        byte mapType=BaseManager.getMapType(name);
        MProxy mapProxy=new MProxy(name);
        if (mapType == MAP_TYPE_SET) {
          proxy=new SetProxy(mapProxy);
        }
 else         if (mapType == MAP_TYPE_LIST) {
          proxy=new ListProxy(mapProxy);
        }
 else {
          proxy=mapProxy;
        }
        proxies.put(name,proxy);
      }
    }
  }
  return proxy;
}
Program: 50807
Project: 50807
Buggy source:
public CollectionProxy(CProxy mapProxy){
  super();
  this.mapProxy=mapProxy;
  this.name=mapProxy.name;
}

Fixed version (ground truth):
public CollectionProxy(MProxy mapProxy){
  super();
  this.mapProxy=mapProxy;
  this.name=mapProxy.name;
}
Program: 50808
Project: 50808
Buggy source:
public SetProxy(CProxy mapProxy){
  super(mapProxy);
}

Fixed version (ground truth):
public SetProxy(MProxy mapProxy){
  super(mapProxy);
}
Program: 50809
Project: 50809
Buggy source:
@Override public int size(){
  return CProxy.this.size();
}

Fixed version (ground truth):
@Override public int size(){
  return MProxy.this.size();
}
Program: 50810
Project: 50810
Buggy source:
public LockProxy(CProxy mapProxy,Object key){
  super();
  this.mapProxy=mapProxy;
  this.key=key;
}

Fixed version (ground truth):
public LockProxy(MProxy mapProxy,Object key){
  super();
  this.mapProxy=mapProxy;
  this.key=key;
}
Program: 50811
Project: 50811
Buggy source:
public TopicProxy(String name){
  super();
  this.name=name;
  if (Config.get().getTopicConfig(getName()).globalOrderingEnabled) {
    qProxy=new QProxy("String_Node_Str" + name);
  }
}

Fixed version (ground truth):
public TopicProxy(String name){
  super();
  this.name=name;
}
Program: 50812
Project: 50812
Buggy source:
public CProxy getCProxy(){
  return mapProxy;
}

Fixed version (ground truth):
public MProxy getCProxy(){
  return mapProxy;
}
Program: 50813
Project: 50813
Buggy source:
public ListProxy(CProxy mapProxy){
  super(mapProxy);
}

Fixed version (ground truth):
public ListProxy(MProxy mapProxy){
  super(mapProxy);
}
Program: 50814
Project: 50814
Buggy source:
public void removeListener(String name,Object listener,Object key){
  Iterator<ListenerItem> it=lsListeners.iterator();
  for (; it.hasNext(); ) {
    ListenerItem listenerItem=it.next();
    if (listener == listenerItem.listener) {
      if (key == null) {
        if (listenerItem.key == null) {
          registerListener(name,null,false,false);
          it.remove();
        }
      }
 else       if (key.equals(listenerItem.key)) {
        registerListener(name,key,false,false);
        it.remove();
      }
    }
  }
}

Fixed version (ground truth):
public synchronized void removeListener(String name,Object listener,Object key){
  Iterator<ListenerItem> it=lsListeners.iterator();
  for (; it.hasNext(); ) {
    ListenerItem listenerItem=it.next();
    if (listener == listenerItem.listener) {
      if (key == null) {
        if (listenerItem.key == null) {
          registerListener(name,null,false,false);
          it.remove();
        }
      }
 else       if (key.equals(listenerItem.key)) {
        registerListener(name,key,false,false);
        it.remove();
      }
    }
  }
}
Program: 50815
Project: 50815
Buggy source:
public void syncForAdd(){
  for (  ListenerItem listenerItem : lsListeners) {
    registerListener(listenerItem.name,listenerItem.key,true,listenerItem.includeValue);
  }
}

Fixed version (ground truth):
public void syncForAdd(Address newAddress){
  for (  ListenerItem listenerItem : lsListeners) {
    Data dataKey=null;
    if (listenerItem.key != null) {
      try {
        dataKey=ThreadContext.get().toData(listenerItem.key);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    sendAddRemoveListener(newAddress,true,listenerItem.name,dataKey,listenerItem.includeValue);
  }
}
Program: 50816
Project: 50816
Buggy source:
public void addListener(String name,Object listener,Object key,boolean includeValue,int listenerType,boolean shouldRemotelyRegister){
  if (shouldRemotelyRegister) {
    boolean remotelyRegister=true;
    for (    ListenerItem listenerItem : lsListeners) {
      if (remotelyRegister) {
        if (listenerItem.listener == listener) {
          if (listenerItem.name.equals(name)) {
            if (key == null) {
              if (listenerItem.key == null) {
                if (!includeValue || listenerItem.includeValue == includeValue) {
                  remotelyRegister=false;
                }
              }
            }
 else {
              if (listenerItem.key != null) {
                if (listenerItem.key.equals(key)) {
                  if (!includeValue || listenerItem.includeValue == includeValue) {
                    remotelyRegister=false;
                  }
                }
              }
            }
          }
        }
      }
    }
    if (remotelyRegister) {
      registerListener(name,key,true,includeValue);
    }
  }
  ListenerItem listenerItem=new ListenerItem(name,key,listener,includeValue,listenerType);
  lsListeners.add(listenerItem);
}

Fixed version (ground truth):
public synchronized void addListener(String name,Object listener,Object key,boolean includeValue,int listenerType,boolean shouldRemotelyRegister){
  if (shouldRemotelyRegister) {
    boolean remotelyRegister=true;
    for (    ListenerItem listenerItem : lsListeners) {
      if (remotelyRegister) {
        if (listenerItem.listener == listener) {
          if (listenerItem.name.equals(name)) {
            if (key == null) {
              if (listenerItem.key == null) {
                if (!includeValue || listenerItem.includeValue == includeValue) {
                  remotelyRegister=false;
                }
              }
            }
 else {
              if (listenerItem.key != null) {
                if (listenerItem.key.equals(key)) {
                  if (!includeValue || listenerItem.includeValue == includeValue) {
                    remotelyRegister=false;
                  }
                }
              }
            }
          }
        }
      }
    }
    if (remotelyRegister) {
      registerListener(name,key,true,includeValue);
    }
  }
  ListenerItem listenerItem=new ListenerItem(name,key,listener,includeValue,listenerType);
  lsListeners.add(listenerItem);
}
Program: 50818
Project: 50818
Buggy source:
private void restorePrivateKeysFromBase58(final File file){
  try (final FileInputStream is=new FileInputStream(file)){
    restoreWallet(WalletUtils.restorePrivateKeysFromBase58(is,Constants.NETWORK_PARAMETERS));
    log.info("String_Node_Str",file);
  }
 catch (  final IOException x) {
    FailureDialogFragment.showDialog(getFragmentManager(),x.toString());
    log.info("String_Node_Str" + file,x);
  }
}

Fixed version (ground truth):
private void restorePrivateKeysFromBase58(final File file){
  try (final FileInputStream is=new FileInputStream(file)){
    restoreWallet(WalletUtils.restorePrivateKeysFromBase58(is,Constants.NETWORK_PARAMETERS));
    log.info("String_Node_Str",file);
  }
 catch (  final IOException x) {
    FailureDialogFragment.showDialog(getFragmentManager(),x.getMessage());
    log.info("String_Node_Str" + file,x);
  }
}
Program: 50819
Project: 50819
Buggy source:
private void restoreWalletFromProtobuf(final File file){
  try (final FileInputStream is=new FileInputStream(file)){
    restoreWallet(WalletUtils.restoreWalletFromProtobuf(is,Constants.NETWORK_PARAMETERS));
    log.info("String_Node_Str",file);
  }
 catch (  final IOException x) {
    FailureDialogFragment.showDialog(getFragmentManager(),x.toString());
    log.info("String_Node_Str" + file,x);
  }
}

Fixed version (ground truth):
private void restoreWalletFromProtobuf(final File file){
  try (final FileInputStream is=new FileInputStream(file)){
    restoreWallet(WalletUtils.restoreWalletFromProtobuf(is,Constants.NETWORK_PARAMETERS));
    log.info("String_Node_Str",file);
  }
 catch (  final IOException x) {
    FailureDialogFragment.showDialog(getFragmentManager(),x.getMessage());
    log.info("String_Node_Str" + file,x);
  }
}
Program: 50820
Project: 50820
Buggy source:
private void restoreWalletFromEncrypted(final File file,final String password){
  try {
    final BufferedReader cipherIn=new BufferedReader(new InputStreamReader(new FileInputStream(file),StandardCharsets.UTF_8));
    final StringBuilder cipherText=new StringBuilder();
    Io.copy(cipherIn,cipherText,Constants.BACKUP_MAX_CHARS);
    cipherIn.close();
    final byte[] plainText=Crypto.decryptBytes(cipherText.toString(),password.toCharArray());
    final InputStream is=new ByteArrayInputStream(plainText);
    restoreWallet(WalletUtils.restoreWalletFromProtobufOrBase58(is,Constants.NETWORK_PARAMETERS));
    log.info("String_Node_Str",file);
  }
 catch (  final IOException x) {
    FailureDialogFragment.showDialog(getFragmentManager(),x.toString());
    log.info("String_Node_Str" + file,x);
  }
}

Fixed version (ground truth):
private void restoreWalletFromEncrypted(final File file,final String password){
  try {
    final BufferedReader cipherIn=new BufferedReader(new InputStreamReader(new FileInputStream(file),StandardCharsets.UTF_8));
    final StringBuilder cipherText=new StringBuilder();
    Io.copy(cipherIn,cipherText,Constants.BACKUP_MAX_CHARS);
    cipherIn.close();
    final byte[] plainText=Crypto.decryptBytes(cipherText.toString(),password.toCharArray());
    final InputStream is=new ByteArrayInputStream(plainText);
    restoreWallet(WalletUtils.restoreWalletFromProtobufOrBase58(is,Constants.NETWORK_PARAMETERS));
    log.info("String_Node_Str",file);
  }
 catch (  final IOException x) {
    FailureDialogFragment.showDialog(getFragmentManager(),x.getMessage());
    log.info("String_Node_Str" + file,x);
  }
}
Program: 50821
Project: 50821
Buggy source:
private void restoreWallet(final Wallet wallet) throws IOException {
  application.replaceWallet(wallet);
  config.disarmBackupReminder();
  SuccessDialogFragment.showDialog(getFragmentManager(),wallet.isEncrypted());
}

Fixed version (ground truth):
private void restoreWallet(final Wallet restoredWallet) throws IOException {
  application.replaceWallet(restoredWallet);
  config.disarmBackupReminder();
  SuccessDialogFragment.showDialog(getFragmentManager(),restoredWallet.isEncrypted());
}
Program: 50822
Project: 50822
Buggy source:
@Override public void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  viewModel=ViewModelProviders.of(this).get(ReportIssueViewModel.class);
  viewModel.wallet.observe(this,new Observer<Wallet>(){
    @Override public void onChanged(    final Wallet wallet){
      if (wallet != null)       positiveButton.setEnabled(true);
    }
  }
);
}

Fixed version (ground truth):
@Override public void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  viewModel=ViewModelProviders.of(this).get(ReportIssueViewModel.class);
}
Program: 50823
Project: 50823
Buggy source:
@Override public void onShow(final DialogInterface d){
  positiveButton=dialog.getButton(DialogInterface.BUTTON_POSITIVE);
  positiveButton.setEnabled(false);
}

Fixed version (ground truth):
@Override public void onShow(final DialogInterface d){
  positiveButton=dialog.getButton(DialogInterface.BUTTON_POSITIVE);
  positiveButton.setEnabled(false);
  viewModel.wallet.observe(ReportIssueDialogFragment.this,new Observer<Wallet>(){
    @Override public void onChanged(    final Wallet wallet){
      positiveButton.setEnabled(true);
    }
  }
);
}
Program: 50824
Project: 50824
Buggy source:
@Override public void onChanged(final Wallet wallet){
  if (wallet != null)   positiveButton.setEnabled(true);
}

Fixed version (ground truth):
@Override public void onChanged(final Wallet wallet){
  positiveButton.setEnabled(true);
}
Program: 50826
Project: 50826
Buggy source:
public static String getAddress(final BluetoothAdapter adapter){
  if (adapter == null)   return null;
  final String address=adapter.getAddress();
  if (!MARSHMELLOW_FAKE_MAC.equals(address))   return address;
  try {
    final Field mServiceField=BluetoothAdapter.class.getDeclaredField("String_Node_Str");
    mServiceField.setAccessible(true);
    final Object mService=mServiceField.get(adapter);
    if (mService == null)     return null;
    return (String)mService.getClass().getMethod("String_Node_Str").invoke(mService);
  }
 catch (  final ReflectiveOperationException x) {
    throw new RuntimeException(x);
  }
}

Fixed version (ground truth):
public static String getAddress(final BluetoothAdapter adapter){
  if (adapter == null)   return null;
  final String address=adapter.getAddress();
  if (!MARSHMELLOW_FAKE_MAC.equals(address))   return address;
  try {
    final Field mServiceField=BluetoothAdapter.class.getDeclaredField("String_Node_Str");
    mServiceField.setAccessible(true);
    final Object mService=mServiceField.get(adapter);
    if (mService == null)     return null;
    return (String)mService.getClass().getMethod("String_Node_Str").invoke(mService);
  }
 catch (  final Exception x) {
    throw new RuntimeException(x);
  }
}
Program: 50827
Project: 50827
Buggy source:
private boolean isValidAmount(final boolean zeroIsValid){
  final String str=textView.getText().toString().trim();
  try {
    if (!str.isEmpty()) {
      final Monetary amount;
      if (localCurrencyCode == null)       amount=inputFormat.parse(str);
 else       amount=inputFormat.parseFiat(localCurrencyCode,str);
      return zeroIsValid || amount.signum() > 0;
    }
  }
 catch (  final Exception x) {
  }
  return false;
}

Fixed version (ground truth):
private boolean isValidAmount(final boolean zeroIsValid){
  final String str=textView.getText().toString().trim();
  try {
    if (!str.isEmpty()) {
      final Monetary amount;
      if (localCurrencyCode == null) {
        amount=inputFormat.parse(str);
        if (((Coin)amount).isGreaterThan(Constants.NETWORK_PARAMETERS.getMaxMoney()))         return false;
      }
 else {
        amount=inputFormat.parseFiat(localCurrencyCode,str);
      }
      return zeroIsValid || amount.signum() > 0;
    }
  }
 catch (  final Exception x) {
  }
  return false;
}
Program: 50828
Project: 50828
Buggy source:
/** 
 * Password based encryption using AES - CBC 256 bits.
 * @param plainBytes The bytes to encrypt
 * @param password The password to use for encryption
 * @return SALT_LENGTH bytes of salt followed by the encrypted bytes.
 * @throws IOException
 */
private static byte[] encrypt(final byte[] plainTextAsBytes,final char[] password) throws IOException {
  try {
    final byte[] salt=new byte[SALT_LENGTH];
    secureRandom.nextBytes(salt);
    final ParametersWithIV key=(ParametersWithIV)getAESPasswordKey(password,salt);
    final BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(true,key);
    final byte[] encryptedBytes=new byte[cipher.getOutputSize(plainTextAsBytes.length)];
    final int length=cipher.processBytes(plainTextAsBytes,0,plainTextAsBytes.length,encryptedBytes,0);
    cipher.doFinal(encryptedBytes,length);
    return concat(salt,encryptedBytes);
  }
 catch (  final InvalidCipherTextException x) {
    throw new IOException("String_Node_Str",x);
  }
catch (  final DataLengthException x) {
    throw new IOException("String_Node_Str",x);
  }
}

Fixed version (ground truth):
/** 
 * Password based encryption using AES - CBC 256 bits.
 * @param plainBytes The bytes to encrypt
 * @param password The password to use for encryption
 * @return SALT_LENGTH bytes of salt followed by the encrypted bytes.
 * @throws IOException
 */
private static byte[] encrypt(final byte[] plainTextAsBytes,final char[] password) throws IOException {
  try {
    final byte[] salt=new byte[SALT_LENGTH];
    secureRandom.nextBytes(salt);
    final ParametersWithIV key=(ParametersWithIV)getAESPasswordKey(password,salt);
    final BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(true,key);
    final byte[] encryptedBytes=new byte[cipher.getOutputSize(plainTextAsBytes.length)];
    final int processLen=cipher.processBytes(plainTextAsBytes,0,plainTextAsBytes.length,encryptedBytes,0);
    final int doFinalLen=cipher.doFinal(encryptedBytes,processLen);
    return concat(salt,Arrays.copyOf(encryptedBytes,processLen + doFinalLen));
  }
 catch (  final InvalidCipherTextException x) {
    throw new IOException("String_Node_Str",x);
  }
catch (  final DataLengthException x) {
    throw new IOException("String_Node_Str",x);
  }
}
Program: 50829
Project: 50829
Buggy source:
/** 
 * Decrypt bytes previously encrypted with this class.
 * @param bytesToDecode The bytes to decrypt
 * @param passwordbThe password to use for decryption
 * @return The decrypted bytes
 * @throws IOException
 */
private static byte[] decrypt(final byte[] bytesToDecode,final char[] password) throws IOException {
  try {
    final byte[] salt=new byte[SALT_LENGTH];
    System.arraycopy(bytesToDecode,0,salt,0,SALT_LENGTH);
    final byte[] cipherBytes=new byte[bytesToDecode.length - SALT_LENGTH];
    System.arraycopy(bytesToDecode,SALT_LENGTH,cipherBytes,0,bytesToDecode.length - SALT_LENGTH);
    final ParametersWithIV key=(ParametersWithIV)getAESPasswordKey(password,salt);
    final BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false,key);
    final byte[] decryptedBytes=new byte[cipher.getOutputSize(cipherBytes.length)];
    final int length=cipher.processBytes(cipherBytes,0,cipherBytes.length,decryptedBytes,0);
    cipher.doFinal(decryptedBytes,length);
    return decryptedBytes;
  }
 catch (  final InvalidCipherTextException x) {
    throw new IOException("String_Node_Str",x);
  }
catch (  final DataLengthException x) {
    throw new IOException("String_Node_Str",x);
  }
}

Fixed version (ground truth):
/** 
 * Decrypt bytes previously encrypted with this class.
 * @param bytesToDecode The bytes to decrypt
 * @param passwordbThe password to use for decryption
 * @return The decrypted bytes
 * @throws IOException
 */
private static byte[] decrypt(final byte[] bytesToDecode,final char[] password) throws IOException {
  try {
    final byte[] salt=new byte[SALT_LENGTH];
    System.arraycopy(bytesToDecode,0,salt,0,SALT_LENGTH);
    final byte[] cipherBytes=new byte[bytesToDecode.length - SALT_LENGTH];
    System.arraycopy(bytesToDecode,SALT_LENGTH,cipherBytes,0,bytesToDecode.length - SALT_LENGTH);
    final ParametersWithIV key=(ParametersWithIV)getAESPasswordKey(password,salt);
    final BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false,key);
    final byte[] decryptedBytes=new byte[cipher.getOutputSize(cipherBytes.length)];
    final int processLen=cipher.processBytes(cipherBytes,0,cipherBytes.length,decryptedBytes,0);
    final int doFinalLen=cipher.doFinal(decryptedBytes,processLen);
    return Arrays.copyOf(decryptedBytes,processLen + doFinalLen);
  }
 catch (  final InvalidCipherTextException x) {
    throw new IOException("String_Node_Str",x);
  }
catch (  final DataLengthException x) {
    throw new IOException("String_Node_Str",x);
  }
}
Program: 50830
Project: 50830
Buggy source:
public static ExchangeRate getExchangeRate(final Cursor cursor){
  final String currencyCode=cursor.getString(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_CURRENCY_CODE));
  final double rate=cursor.getDouble(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_RATE));
  final String source=cursor.getString(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_SOURCE));
  return new ExchangeRate(currencyCode,rate,source);
}

Fixed version (ground truth):
public static ExchangeRate getExchangeRate(final Cursor cursor){
  final String currencyCode=cursor.getString(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_CURRENCY_CODE));
  final BigInteger rate=BigInteger.valueOf(cursor.getLong(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_RATE)));
  final String source=cursor.getString(cursor.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_SOURCE));
  return new ExchangeRate(currencyCode,rate,source);
}
Program: 50831
Project: 50831
Buggy source:
private static Map<String,ExchangeRate> getBitcoinCharts(){
  try {
    final URL URL=new URL("String_Node_Str");
    final URLConnection connection=URL.openConnection();
    connection.connect();
    final StringBuilder content=new StringBuilder();
    Reader reader=null;
    try {
      reader=new InputStreamReader(new BufferedInputStream(connection.getInputStream(),1024));
      IOUtils.copy(reader,content);
      final Map<String,ExchangeRate> rates=new TreeMap<String,ExchangeRate>();
      final JSONObject head=new JSONObject(content.toString());
      for (final Iterator<String> i=head.keys(); i.hasNext(); ) {
        final String currencyCode=i.next();
        if (!"String_Node_Str".equals(currencyCode)) {
          final JSONObject o=head.getJSONObject(currencyCode);
          double rate=o.optDouble("String_Node_Str",0);
          if (rate == 0)           rate=o.optDouble("String_Node_Str",0);
          if (rate == 0)           rate=o.optDouble("String_Node_Str",0);
          if (rate != 0)           rates.put(currencyCode,new ExchangeRate(currencyCode,rate,URL.getHost()));
        }
      }
      return rates;
    }
  finally {
      if (reader != null)       reader.close();
    }
  }
 catch (  final IOException x) {
    x.printStackTrace();
  }
catch (  final JSONException x) {
    x.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
private static Map<String,ExchangeRate> getBitcoinCharts(){
  try {
    final URL URL=new URL("String_Node_Str");
    final URLConnection connection=URL.openConnection();
    connection.connect();
    final StringBuilder content=new StringBuilder();
    Reader reader=null;
    try {
      reader=new InputStreamReader(new BufferedInputStream(connection.getInputStream(),1024));
      IOUtils.copy(reader,content);
      final Map<String,ExchangeRate> rates=new TreeMap<String,ExchangeRate>();
      final JSONObject head=new JSONObject(content.toString());
      for (final Iterator<String> i=head.keys(); i.hasNext(); ) {
        final String currencyCode=i.next();
        if (!"String_Node_Str".equals(currencyCode)) {
          final JSONObject o=head.getJSONObject(currencyCode);
          String rate=o.optString("String_Node_Str",null);
          if (rate == null)           rate=o.optString("String_Node_Str",null);
          if (rate == null)           rate=o.optString("String_Node_Str",null);
          if (rate != null)           rates.put(currencyCode,new ExchangeRate(currencyCode,Utils.toNanoCoins(rate),URL.getHost()));
        }
      }
      return rates;
    }
  finally {
      if (reader != null)       reader.close();
    }
  }
 catch (  final IOException x) {
    x.printStackTrace();
  }
catch (  final JSONException x) {
    x.printStackTrace();
  }
  return null;
}
Program: 50832
Project: 50832
Buggy source:
public ExchangeRate(final String currencyCode,final double rate,final String source){
  this.currencyCode=currencyCode;
  this.rate=rate;
  this.source=source;
}

Fixed version (ground truth):
public ExchangeRate(final String currencyCode,final BigInteger rate,final String source){
  this.currencyCode=currencyCode;
  this.rate=rate;
  this.source=source;
}
Program: 50833
Project: 50833
Buggy source:
private static Map<String,ExchangeRate> getBlockchainInfo(){
  try {
    final URL URL=new URL("String_Node_Str");
    final URLConnection connection=URL.openConnection();
    connection.connect();
    final StringBuilder content=new StringBuilder();
    Reader reader=null;
    try {
      reader=new InputStreamReader(new BufferedInputStream(connection.getInputStream(),1024));
      IOUtils.copy(reader,content);
      final Map<String,ExchangeRate> rates=new TreeMap<String,ExchangeRate>();
      final JSONObject head=new JSONObject(content.toString());
      for (final Iterator<String> i=head.keys(); i.hasNext(); ) {
        final String currencyCode=i.next();
        final JSONObject o=head.getJSONObject(currencyCode);
        final double rate=o.optDouble("String_Node_Str",0);
        if (rate != 0)         rates.put(currencyCode,new ExchangeRate(currencyCode,rate,URL.getHost()));
      }
      return rates;
    }
  finally {
      if (reader != null)       reader.close();
    }
  }
 catch (  final IOException x) {
    x.printStackTrace();
  }
catch (  final JSONException x) {
    x.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
private static Map<String,ExchangeRate> getBlockchainInfo(){
  try {
    final URL URL=new URL("String_Node_Str");
    final URLConnection connection=URL.openConnection();
    connection.connect();
    final StringBuilder content=new StringBuilder();
    Reader reader=null;
    try {
      reader=new InputStreamReader(new BufferedInputStream(connection.getInputStream(),1024));
      IOUtils.copy(reader,content);
      final Map<String,ExchangeRate> rates=new TreeMap<String,ExchangeRate>();
      final JSONObject head=new JSONObject(content.toString());
      for (final Iterator<String> i=head.keys(); i.hasNext(); ) {
        final String currencyCode=i.next();
        final JSONObject o=head.getJSONObject(currencyCode);
        final String rate=o.optString("String_Node_Str",null);
        if (rate != null)         rates.put(currencyCode,new ExchangeRate(currencyCode,Utils.toNanoCoins(rate),URL.getHost()));
      }
      return rates;
    }
  finally {
      if (reader != null)       reader.close();
    }
  }
 catch (  final IOException x) {
    x.printStackTrace();
  }
catch (  final JSONException x) {
    x.printStackTrace();
  }
  return null;
}
Program: 50834
Project: 50834
Buggy source:
@Override public Cursor query(final Uri uri,final String[] projection,final String selection,final String[] selectionArgs,final String sortOrder){
  final long now=System.currentTimeMillis();
  if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) {
    Map<String,ExchangeRate> newExchangeRates=getBitcoinCharts();
    if (exchangeRates == null && newExchangeRates == null)     newExchangeRates=getBlockchainInfo();
    if (newExchangeRates != null) {
      exchangeRates=newExchangeRates;
      lastUpdated=now;
    }
  }
  if (exchangeRates == null)   return null;
  final MatrixCursor cursor=new MatrixCursor(new String[]{BaseColumns._ID,KEY_CURRENCY_CODE,KEY_RATE,KEY_SOURCE});
  if (selection == null) {
    for (    final Map.Entry<String,ExchangeRate> entry : exchangeRates.entrySet()) {
      final ExchangeRate rate=entry.getValue();
      cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate).add(rate.source);
    }
  }
 else   if (selection.equals(KEY_CURRENCY_CODE)) {
    final String code=selectionArgs[0];
    final ExchangeRate rate=exchangeRates.get(code);
    cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate).add(rate.source);
  }
  return cursor;
}

Fixed version (ground truth):
@Override public Cursor query(final Uri uri,final String[] projection,final String selection,final String[] selectionArgs,final String sortOrder){
  final long now=System.currentTimeMillis();
  if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) {
    Map<String,ExchangeRate> newExchangeRates=getBitcoinCharts();
    if (exchangeRates == null && newExchangeRates == null)     newExchangeRates=getBlockchainInfo();
    if (newExchangeRates != null) {
      exchangeRates=newExchangeRates;
      lastUpdated=now;
    }
  }
  if (exchangeRates == null)   return null;
  final MatrixCursor cursor=new MatrixCursor(new String[]{BaseColumns._ID,KEY_CURRENCY_CODE,KEY_RATE,KEY_SOURCE});
  if (selection == null) {
    for (    final Map.Entry<String,ExchangeRate> entry : exchangeRates.entrySet()) {
      final ExchangeRate rate=entry.getValue();
      cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue()).add(rate.source);
    }
  }
 else   if (selection.equals(KEY_CURRENCY_CODE)) {
    final String code=selectionArgs[0];
    final ExchangeRate rate=exchangeRates.get(code);
    cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue()).add(rate.source);
  }
  return cursor;
}
Program: 50836
Project: 50836
Buggy source:
private void updateAppearance(){
  if (exchangeRate != null) {
    localAmountView.setEnabled(true);
    final BigDecimal bdRate=new BigDecimal(exchangeRate.rate);
    if (exchangeDirection) {
      final BigInteger btcAmount=btcAmountView.getAmount();
      if (btcAmount != null) {
        localAmountView.setAmount(null);
        localAmountView.setHint(new BigDecimal(btcAmount).multiply(bdRate).toBigInteger());
        btcAmountView.setHint(null);
      }
    }
 else {
      final BigInteger localAmount=localAmountView.getAmount();
      if (localAmount != null) {
        btcAmountView.setAmount(null);
        btcAmountView.setHint(new BigDecimal(localAmount).divide(bdRate,RoundingMode.HALF_UP).toBigInteger());
        localAmountView.setHint(null);
      }
    }
    exchangeRateView.setText(getString(R.string.amount_calculator_dialog_exchange_rate,exchangeCurrency,WalletUtils.formatValue(WalletUtils.localValue(Utils.COIN,bdRate)),exchangeRate.source));
  }
 else {
    localAmountView.setEnabled(false);
    exchangeRateView.setText(R.string.amount_calculator_dialog_exchange_rate_not_available);
  }
}

Fixed version (ground truth):
private void updateAppearance(){
  if (exchangeRate != null) {
    localAmountView.setEnabled(true);
    if (exchangeDirection) {
      final BigInteger btcAmount=btcAmountView.getAmount();
      if (btcAmount != null) {
        localAmountView.setAmount(null);
        localAmountView.setHint(WalletUtils.localValue(btcAmount,exchangeRate.rate));
        btcAmountView.setHint(null);
      }
    }
 else {
      final BigInteger localAmount=localAmountView.getAmount();
      if (localAmount != null) {
        btcAmountView.setAmount(null);
        btcAmountView.setHint(WalletUtils.btcValue(localAmount,exchangeRate.rate));
        localAmountView.setHint(null);
      }
    }
    exchangeRateView.setText(getString(R.string.amount_calculator_dialog_exchange_rate,exchangeCurrency,WalletUtils.formatValue(WalletUtils.localValue(Utils.COIN,exchangeRate.rate)),exchangeRate.source));
  }
 else {
    localAmountView.setEnabled(false);
    exchangeRateView.setText(R.string.amount_calculator_dialog_exchange_rate_not_available);
  }
}
Program: 50837
Project: 50837
Buggy source:
private void done(){
  final BigInteger amount=exchangeDirection ? btcAmountView.getAmount() : new BigDecimal(localAmountView.getAmount()).divide(new BigDecimal(exchangeRate.rate),RoundingMode.HALF_UP).toBigInteger();
  ((Listener)getTargetFragment()).useCalculatedAmount(amount);
  dismiss();
}

Fixed version (ground truth):
private void done(){
  final BigInteger amount=exchangeDirection ? btcAmountView.getAmount() : WalletUtils.btcValue(localAmountView.getAmount(),exchangeRate.rate);
  ((Listener)getTargetFragment()).useCalculatedAmount(amount);
  dismiss();
}
Program: 50838
Project: 50838
Buggy source:
public void setHint(final BigInteger amount){
  final SpannableStringBuilder hint;
  if (amount != null)   hint=new SpannableStringBuilder(WalletUtils.formatValue(amount));
 else   hint=new SpannableStringBuilder("String_Node_Str");
  WalletUtils.formatSignificant(hint,smallerInsignificant);
  textView.setHint(hint);
}

Fixed version (ground truth):
public void setHint(final BigInteger amount){
  final SpannableStringBuilder hint;
  if (amount != null)   hint=new SpannableStringBuilder(WalletUtils.formatValue(amount,precision));
 else   hint=new SpannableStringBuilder("String_Node_Str");
  WalletUtils.formatSignificant(hint,smallerInsignificant);
  textView.setHint(hint);
}
Program: 50839
Project: 50839
Buggy source:
public void setAmount(final BigInteger amount){
  if (amount != null)   textView.setText(amountSigned ? WalletUtils.formatValue(amount,Constants.CURRENCY_PLUS_SIGN,Constants.CURRENCY_MINUS_SIGN) : WalletUtils.formatValue(amount));
 else   textView.setText(null);
}

Fixed version (ground truth):
public void setAmount(final BigInteger amount){
  if (amount != null)   textView.setText(amountSigned ? WalletUtils.formatValue(amount,Constants.CURRENCY_PLUS_SIGN,Constants.CURRENCY_MINUS_SIGN,precision) : WalletUtils.formatValue(amount,precision));
 else   textView.setText(null);
}
Program: 50840
Project: 50840
Buggy source:
@Override public void bindView(final View view,final Context context,final Cursor cursor){
  final ExchangeRate exchangeRate=ExchangeRatesProvider.getExchangeRate(cursor);
  final BigDecimal bdRate=new BigDecimal(exchangeRate.rate);
  final boolean isDefaultCurrency=exchangeRate.currencyCode.equals(defaultCurrency);
  view.setBackgroundResource(isDefaultCurrency ? R.color.bg_less_bright : R.color.bg_bright);
  final View defaultView=view.findViewById(R.id.exchange_rate_row_default);
  defaultView.setVisibility(isDefaultCurrency ? View.VISIBLE : View.INVISIBLE);
  final TextView currencyCodeView=(TextView)view.findViewById(R.id.exchange_rate_row_currency_code);
  currencyCodeView.setText(exchangeRate.currencyCode);
  final CurrencyAmountView rateView=(CurrencyAmountView)view.findViewById(R.id.exchange_rate_row_rate);
  rateView.setCurrencyCode(null);
  rateView.setAmount(WalletUtils.localValue(Utils.COIN,bdRate));
  final CurrencyAmountView walletView=(CurrencyAmountView)view.findViewById(R.id.exchange_rate_row_balance);
  walletView.setCurrencyCode(null);
  walletView.setAmount(WalletUtils.localValue(balance,bdRate));
  walletView.setStrikeThru(Constants.TEST);
  walletView.setTextColor(getResources().getColor(R.color.fg_less_significant));
}

Fixed version (ground truth):
@Override public void bindView(final View view,final Context context,final Cursor cursor){
  final ExchangeRate exchangeRate=ExchangeRatesProvider.getExchangeRate(cursor);
  final boolean isDefaultCurrency=exchangeRate.currencyCode.equals(defaultCurrency);
  view.setBackgroundResource(isDefaultCurrency ? R.color.bg_less_bright : R.color.bg_bright);
  final View defaultView=view.findViewById(R.id.exchange_rate_row_default);
  defaultView.setVisibility(isDefaultCurrency ? View.VISIBLE : View.INVISIBLE);
  final TextView currencyCodeView=(TextView)view.findViewById(R.id.exchange_rate_row_currency_code);
  currencyCodeView.setText(exchangeRate.currencyCode);
  final CurrencyAmountView rateView=(CurrencyAmountView)view.findViewById(R.id.exchange_rate_row_rate);
  rateView.setCurrencyCode(null);
  rateView.setPrecision(Constants.LOCAL_PRECISION);
  rateView.setAmount(WalletUtils.localValue(Utils.COIN,exchangeRate.rate));
  final CurrencyAmountView walletView=(CurrencyAmountView)view.findViewById(R.id.exchange_rate_row_balance);
  walletView.setCurrencyCode(null);
  walletView.setPrecision(Constants.LOCAL_PRECISION);
  walletView.setAmount(WalletUtils.localValue(balance,exchangeRate.rate));
  walletView.setStrikeThru(Constants.TEST);
  walletView.setTextColor(getResources().getColor(R.color.fg_less_significant));
}
Program: 50842
Project: 50842
Buggy source:
@Override public void onViewCreated(final View view,final Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  viewBalance=(CurrencyAmountView)view.findViewById(R.id.wallet_balance);
  viewBalanceLocal=(CurrencyAmountView)view.findViewById(R.id.wallet_balance_local);
  viewBalanceLocal.setSmallerInsignificant(false);
  viewBalanceLocal.setStrikeThru(Constants.TEST);
}

Fixed version (ground truth):
@Override public void onViewCreated(final View view,final Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  viewBalance=(CurrencyAmountView)view.findViewById(R.id.wallet_balance);
  viewBalanceLocal=(CurrencyAmountView)view.findViewById(R.id.wallet_balance_local);
  viewBalanceLocal.setPrecision(Constants.LOCAL_PRECISION);
  viewBalanceLocal.setSmallerInsignificant(false);
  viewBalanceLocal.setStrikeThru(Constants.TEST);
}
Program: 50843
Project: 50843
Buggy source:
private void updateView(){
  if (!showLocalBalance)   viewBalanceLocal.setVisibility(View.GONE);
  if (balance != null) {
    viewBalance.setVisibility(View.VISIBLE);
    viewBalance.setAmount(balance);
    if (showLocalBalance) {
      if (exchangeRate != null) {
        final BigInteger balance=wallet.getBalance(BalanceType.ESTIMATED);
        final BigDecimal bdRate=new BigDecimal(exchangeRate.rate);
        final BigInteger localValue=WalletUtils.localValue(balance,bdRate);
        viewBalanceLocal.setVisibility(View.VISIBLE);
        viewBalanceLocal.setCurrencyCode(Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.currencyCode);
        viewBalanceLocal.setAmount(localValue);
        viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
      }
 else {
        viewBalanceLocal.setVisibility(View.INVISIBLE);
      }
    }
  }
 else {
    viewBalance.setVisibility(View.INVISIBLE);
  }
}

Fixed version (ground truth):
private void updateView(){
  if (!showLocalBalance)   viewBalanceLocal.setVisibility(View.GONE);
  if (balance != null) {
    viewBalance.setVisibility(View.VISIBLE);
    viewBalance.setAmount(balance);
    if (showLocalBalance) {
      if (exchangeRate != null) {
        final BigInteger balance=wallet.getBalance(BalanceType.ESTIMATED);
        final BigInteger localValue=WalletUtils.localValue(balance,exchangeRate.rate);
        viewBalanceLocal.setVisibility(View.VISIBLE);
        viewBalanceLocal.setCurrencyCode(Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.currencyCode);
        viewBalanceLocal.setAmount(localValue);
        viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
      }
 else {
        viewBalanceLocal.setVisibility(View.INVISIBLE);
      }
    }
  }
 else {
    viewBalance.setVisibility(View.INVISIBLE);
  }
}
Program: 50844
Project: 50844
Buggy source:
public static String formatValue(final BigInteger value,final String plusSign,final String minusSign){
  final boolean negative=value.compareTo(BigInteger.ZERO) < 0;
  final BigInteger absValue=value.abs();
  final String sign=negative ? minusSign : plusSign;
  final int coins=absValue.divide(Utils.COIN).intValue();
  final int cents=absValue.remainder(Utils.COIN).intValue();
  if (cents % 1000000 == 0)   return String.format(Locale.US,"String_Node_Str",sign,coins,cents / 1000000);
 else   if (cents % 10000 == 0)   return String.format(Locale.US,"String_Node_Str",sign,coins,cents / 10000);
 else   return String.format(Locale.US,"String_Node_Str",sign,coins,cents);
}

Fixed version (ground truth):
public static String formatValue(final BigInteger value,final String plusSign,final String minusSign,final int precision){
  final boolean negative=value.compareTo(BigInteger.ZERO) < 0;
  final BigInteger absValue=value.abs();
  final String sign=negative ? minusSign : plusSign;
  final int coins=absValue.divide(Utils.COIN).intValue();
  final int cents=absValue.remainder(Utils.COIN).intValue();
  if (cents % 1000000 == 0 || precision <= 2)   return String.format(Locale.US,"String_Node_Str",sign,coins,cents / 1000000);
 else   if (cents % 10000 == 0 || precision <= 4)   return String.format(Locale.US,"String_Node_Str",sign,coins,cents / 10000);
 else   return String.format(Locale.US,"String_Node_Str",sign,coins,cents);
}
Program: 50845
Project: 50845
Buggy source:
public static BigInteger localValue(final BigInteger btcValue,final BigDecimal exchangeRate){
  final BigDecimal value=new BigDecimal(btcValue).multiply(exchangeRate);
  final BigDecimal remainder=value.remainder(LOCAL_VALUE_PRECISION);
  return value.subtract(remainder).toBigInteger();
}

Fixed version (ground truth):
public static BigInteger localValue(final BigInteger btcValue,final BigInteger rate){
  return btcValue.multiply(rate).divide(Utils.COIN);
}
Program: 50846
Project: 50846
Buggy source:
public void onClick(final DialogInterface dialog,final int which){
  stackTraceFile.delete();
  dialog.dismiss();
}

Fixed version (ground truth):
public void onClick(final DialogInterface dialog,final int which){
  stackTraceFile.delete();
}