nus-yam/ex-repair huggingface dataset:
Program: 24933
Project: 24933
Buggy source:
/** 
 * Test of persist method, of class ProblemHibernateDAO.
 */
@Test public void testCreate() throws Exception {
  String title="String_Node_Str";
  String contact="String_Node_Str";
  String doc="String_Node_Str";
  byte priority=3;
  Problem problem=new Problem();
  problem.setTitle(title);
  problem.setContact(contact);
  problem.setDoc(doc);
  problem.setPriority(priority);
  ProblemDAO dao=(ProblemDAO)PersistenceContext.getInstance().getBean("String_Node_Str");
  Problem perProblem=dao.persist(problem);
  assertNotNull("String_Node_Str",perProblem.getId());
  assertEquals("String_Node_Str",title,perProblem.getTitle());
  assertEquals("String_Node_Str",contact,perProblem.getContact());
  assertEquals("String_Node_Str",doc,perProblem.getDoc());
  assertEquals("String_Node_Str",priority,perProblem.getPriority());
  PreparedStatement stmt=connection.prepareStatement("String_Node_Str");
  stmt.setLong(1,perProblem.getId());
  ResultSet results=stmt.executeQuery();
  assertTrue(results.next());
  assertEquals("String_Node_Str",title,results.getString(1));
  assertEquals("String_Node_Str",contact,results.getString(2));
  assertEquals("String_Node_Str",doc,results.getString(3));
  assertEquals("String_Node_Str",priority,results.getByte(4));
}

Fixed version (ground truth):
/** 
 * Test of persist method, of class ProblemHibernateDAO.
 */
@Test public void testCreate() throws Exception {
  String title="String_Node_Str";
  String contact="String_Node_Str";
  String doc="String_Node_Str";
  byte priority=3;
  List<String> procedures=new ArrayList<String>(2);
  procedures.add("String_Node_Str");
  procedures.add("String_Node_Str");
  Problem problem=new Problem();
  problem.setTitle(title);
  problem.setContact(contact);
  problem.setDoc(doc);
  problem.setPriority(priority);
  problem.setProcedures(procedures);
  ProblemDAO dao=(ProblemDAO)TestPersistenceContext.getInstance().getBean("String_Node_Str");
  Problem perProblem=dao.persist(problem);
  assertNotNull("String_Node_Str",perProblem.getId());
  assertEquals("String_Node_Str",title,perProblem.getTitle());
  assertEquals("String_Node_Str",contact,perProblem.getContact());
  assertEquals("String_Node_Str",doc,perProblem.getDoc());
  assertEquals("String_Node_Str",priority,perProblem.getPriority());
  assertEquals("String_Node_Str",procedures,perProblem.getProcedures());
  PreparedStatement stmt=connection.prepareStatement("String_Node_Str");
  stmt.setInt(1,perProblem.getId());
  ResultSet results=stmt.executeQuery();
  assertTrue(results.next());
  assertEquals("String_Node_Str",title,results.getString(1));
  assertEquals("String_Node_Str",contact,results.getString(2));
  assertEquals("String_Node_Str",doc,results.getString(3));
  assertEquals("String_Node_Str",priority,results.getByte(4));
  PreparedStatement stmt2=connection.prepareStatement("String_Node_Str");
  stmt2.setInt(1,perProblem.getId());
  ResultSet results2=stmt2.executeQuery();
  int i;
  for (i=0; results2.next(); i++) {
    assertEquals("String_Node_Str" + i,procedures.get(i),results2.getString(1));
  }
  assertEquals("String_Node_Str",procedures.size(),i);
}
Program: 24934
Project: 24934
Buggy source:
@BeforeClass public static void setUpBefore() throws Exception {
  connection=TestConnectionHelper.getConnection();
}

Fixed version (ground truth):
@BeforeClass public static void setUpBefore() throws Exception {
  connection=TestConnectionHelper.getConnection();
  TestConnectionHelper.generateTestData();
}
Program: 24935
Project: 24935
Buggy source:
/** 
 * Retrieves a <code>Task</code> from the database by its unique id.
 * @param taskid Unique id of the <code>Task</code>to retrieve.
 * @return <code>Task</code> instance from the database or<code>null</code> if id cannot be found.
 */
public Task getTask(Long taskid);

Fixed version (ground truth):
/** 
 * Retrieves a <code>Task</code> from the database by its unique id.
 * @param taskid Unique id of the <code>Task</code>to retrieve.
 * @return <code>Task</code> instance from the database or<code>null</code> if id cannot be found.
 */
public Task getTask(int taskid);
Program: 24936
Project: 24936
Buggy source:
public Task getTask(Long taskid){
  logger.debug("String_Node_Str" + (long)taskid);
  List result=getHibernateTemplate().findByNamedQuery("String_Node_Str",taskid);
  if (result.size() <= 0) {
    logger.debug("String_Node_Str");
    return null;
  }
 else {
    logger.debug("String_Node_Str");
    return (Task)result.get(0);
  }
}

Fixed version (ground truth):
public Task getTask(int taskid){
  logger.debug("String_Node_Str" + taskid);
  List result=getHibernateTemplate().findByNamedQuery("String_Node_Str",taskid);
  if (result.size() <= 0) {
    logger.debug("String_Node_Str");
    return null;
  }
 else {
    logger.debug("String_Node_Str");
    return (Task)result.get(0);
  }
}
Program: 24937
Project: 24937
Buggy source:
/** 
 * Test of delete method, of class TaskHibernateDAO.
 */
@Test @Ignore public void testDelete() throws Exception {
  Task task=new Task();
  task.setId(1);
  task.setTitle("String_Node_Str");
  task.setDetails("String_Node_Str");
  task.setDoc("String_Node_Str");
  task.setStartDate(new SimpleDateFormat("String_Node_Str").parse("String_Node_Str"));
  task.setDays((short)1);
  task.setWeeks((byte)1);
  task.setMonths((short)1);
  TaskDAO dao=(TaskDAO)PersistenceContext.getInstance().getBean("String_Node_Str");
  dao.delete(task);
  PreparedStatement statement=null;
  ResultSet results=null;
  try {
    statement=connection.prepareStatement("String_Node_Str");
    statement.setLong(1,1L);
    results=statement.executeQuery();
    assertFalse(results.next());
  }
  finally {
    if (statement != null)     statement.close();
    if (results != null)     results.close();
  }
}

Fixed version (ground truth):
/** 
 * Test of delete method, of class TaskHibernateDAO.
 */
@Test @Ignore public void testDelete() throws Exception {
  Task task=new Task();
  task.setId(1);
  task.setTitle("String_Node_Str");
  task.setDetails("String_Node_Str");
  task.setDoc("String_Node_Str");
  task.setStartDate(new SimpleDateFormat("String_Node_Str").parse("String_Node_Str"));
  task.setDays((short)1);
  task.setWeeks((byte)1);
  task.setMonths((short)1);
  TaskDAO dao=(TaskDAO)TestPersistenceContext.getInstance().getBean("String_Node_Str");
  dao.delete(task);
  PreparedStatement statement=null;
  ResultSet results=null;
  try {
    statement=connection.prepareStatement("String_Node_Str");
    statement.setLong(1,1L);
    results=statement.executeQuery();
    assertFalse(results.next());
  }
  finally {
    if (statement != null)     statement.close();
    if (results != null)     results.close();
  }
}
Program: 24938
Project: 24938
Buggy source:
/** 
 * Test of getTask method, of class TaskHibernateDAO.
 */
@Test @Ignore public void testGetTask() throws Exception {
  TaskDAO dao=(TaskDAO)PersistenceContext.getInstance().getBean("String_Node_Str");
  Task result=dao.getTask(2L);
  assertNotNull(result);
  assertEquals("String_Node_Str","String_Node_Str",result.getTitle());
  assertEquals("String_Node_Str","String_Node_Str",result.getDetails());
  assertEquals("String_Node_Str","String_Node_Str",result.getDoc());
  assertEquals("String_Node_Str",(byte)1,result.getInputType());
  assertEquals("String_Node_Str",new SimpleDateFormat("String_Node_Str").parse("String_Node_Str"),result.getStartDate());
  assertEquals("String_Node_Str",1,(short)result.getDays());
  assertEquals("String_Node_Str",1,(byte)result.getWeeks());
  assertEquals("String_Node_Str",1,(short)result.getMonths());
}

Fixed version (ground truth):
/** 
 * Test of getTask method, of class TaskHibernateDAO.
 */
@Test @Ignore public void testGetTask() throws Exception {
  TaskDAO dao=(TaskDAO)TestPersistenceContext.getInstance().getBean("String_Node_Str");
  Task result=dao.getTask(2);
  assertNotNull(result);
  assertEquals("String_Node_Str","String_Node_Str",result.getTitle());
  assertEquals("String_Node_Str","String_Node_Str",result.getDetails());
  assertEquals("String_Node_Str","String_Node_Str",result.getDoc());
  assertEquals("String_Node_Str",(byte)1,result.getInputType());
  assertEquals("String_Node_Str",new SimpleDateFormat("String_Node_Str").parse("String_Node_Str"),result.getStartDate());
  assertEquals("String_Node_Str",1,(short)result.getDays());
  assertEquals("String_Node_Str",1,(byte)result.getWeeks());
  assertEquals("String_Node_Str",1,(short)result.getMonths());
}
Program: 24940
Project: 24940
Buggy source:
public boolean isErrorRule(){
  return ruleIsMandatory() || ruleIsOptional() || (ruleisGuideline() && isError == true);
}

Fixed version (ground truth):
public boolean isErrorRule(){
  return ruleIsMandatory() || ((ruleIsOptional() || ruleisGuideline()) && isError == true);
}
Program: 24941
Project: 24941
Buggy source:
private boolean match(final int a,final boolean knownValue){
  return a == (knownValue ? ON : OFF);
}

Fixed version (ground truth):
private boolean match(final int a,final boolean knownValue){
  return a == (knownValue ? ON : OFF) || a == UNKNOWN;
}
Program: 24942
Project: 24942
Buggy source:
private void updateAllPreferences(){
  updateModeLocalPreferences();
  initialMoveDelay=Main.pref.getInteger(prefKey("String_Node_Str"),-1);
}

Fixed version (ground truth):
private void updateAllPreferences(){
  updateModeLocalPreferences();
}
Program: 24943
Project: 24943
Buggy source:
private void updateModeLocalPreferences(){
  snapThreshold=Main.pref.getDouble(prefKey("String_Node_Str"),0.35);
  snapDefault=Main.pref.getBoolean(prefKey("String_Node_Str"),true);
  copyTagsDefault=Main.pref.getBoolean(prefKey("String_Node_Str"),true);
  snapModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  copyTagsModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  addToSelectionModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  toggleSelectedModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  setSelectedModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
private void updateModeLocalPreferences(){
  snapThreshold=Main.pref.getDouble(prefKey("String_Node_Str"),0.35);
  snapDefault=Main.pref.getBoolean(prefKey("String_Node_Str"),true);
  copyTagsDefault=Main.pref.getBoolean(prefKey("String_Node_Str"),true);
  initialMoveDelay=Main.pref.getInteger(prefKey("String_Node_Str"),200);
  snapModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  copyTagsModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  addToSelectionModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  toggleSelectedModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
  setSelectedModifierCombo=new ModifiersSpec(getStringPref("String_Node_Str","String_Node_Str"));
}
Program: 24944
Project: 24944
Buggy source:
private boolean initParallelWays(Point p,boolean copyTags){
  referenceSegment=mv.getNearestWaySegment(p,Way.isUsablePredicate,true);
  if (referenceSegment == null)   return false;
  if (!sourceWays.contains(referenceSegment.way)) {
    clearSourceWays();
    addSourceWay(referenceSegment.way);
  }
  try {
    int referenceWayIndex=-1;
    int i=0;
    for (    Way w : sourceWays) {
      if (w == referenceSegment.way) {
        referenceWayIndex=i;
        break;
      }
    }
    pWays=new ParallelWays(sourceWays,copyTags,referenceWayIndex);
    pWays.commit(null);
    getCurrentDataSet().setSelected(pWays.ways);
    return true;
  }
 catch (  IllegalArgumentException e) {
    pWays=null;
    return false;
  }
}

Fixed version (ground truth):
private boolean initParallelWays(Point p,boolean copyTags){
  referenceSegment=mv.getNearestWaySegment(p,Way.isUsablePredicate,true);
  if (referenceSegment == null)   return false;
  if (!sourceWays.contains(referenceSegment.way)) {
    clearSourceWays();
    addSourceWay(referenceSegment.way);
  }
  try {
    int referenceWayIndex=-1;
    int i=0;
    for (    Way w : sourceWays) {
      if (w == referenceSegment.way) {
        referenceWayIndex=i;
        break;
      }
    }
    pWays=new ParallelWays(sourceWays,copyTags,referenceWayIndex);
    pWays.commit();
    getCurrentDataSet().setSelected(pWays.ways);
    return true;
  }
 catch (  IllegalArgumentException e) {
    pWays=null;
    return false;
  }
}
Program: 24945
Project: 24945
Buggy source:
public void commit(DataSet ds){
  SequenceCommand undoCommand=new SequenceCommand("String_Node_Str",makeAddWayAndNodesCommandList());
  Main.main.undoRedo.add(undoCommand);
}

Fixed version (ground truth):
public void commit(){
  SequenceCommand undoCommand=new SequenceCommand("String_Node_Str",makeAddWayAndNodesCommandList());
  Main.main.undoRedo.add(undoCommand);
}
Program: 24946
Project: 24946
Buggy source:
public void stop(){
  mThread.getHandler().sendEmptyMessage(R.id.stop_camera_message);
}

Fixed version (ground truth):
public void stop(){
  mState.stop(mCamera,this);
}
Program: 24947
Project: 24947
Buggy source:
public void switchToPortrait(){
  mThread.getHandler().sendEmptyMessage(R.id.rotate_camera_message);
}

Fixed version (ground truth):
public void switchToPortrait(){
  mState.switchToPortrait(mCamera,this);
}
Program: 24948
Project: 24948
Buggy source:
public void start(SurfaceHolder holder){
  Handler handler=mThread.getHandler();
  handler.sendMessage(handler.obtainMessage(R.id.start_camera_message,holder));
}

Fixed version (ground truth):
public void start(SurfaceHolder holder){
  mState.start(mCamera,holder,this);
}
Program: 24949
Project: 24949
Buggy source:
public void close(){
  mThread.getHandler().sendEmptyMessage(R.id.close_camera_message);
  stopThread();
}

Fixed version (ground truth):
public void close(){
  mState.close(mCamera,this);
}
Program: 24950
Project: 24950
Buggy source:
public void open(){
  startThread(mQRCodeEvaluator);
  mThread.getHandler().sendEmptyMessage(R.id.open_camera_message);
}

Fixed version (ground truth):
public void open(){
  mCamera=mState.open(this);
}
Program: 24951
Project: 24951
Buggy source:
public PreviewHandler(IFrameEvaluator evaluator,Camera camera){
  mFrameEvaluator=evaluator;
  int previewFrameSize=CameraUtils.getPreviewFrameSize(camera);
  for (int i=0; i < NUMBER_PREVIEW_BUFFERS; ++i) {
    ByteBuffer buffer=ByteBuffer.allocate(previewFrameSize);
    mPreviewBuffers.add(buffer);
  }
  addCallbackBuffers(camera);
}

Fixed version (ground truth):
public PreviewHandler(Camera camera){
  int previewFrameSize=CameraUtils.getPreviewFrameSize(camera);
  for (int i=0; i < NUMBER_PREVIEW_BUFFERS; ++i) {
    ByteBuffer buffer=ByteBuffer.allocate(previewFrameSize);
    mPreviewBuffers.add(buffer);
  }
  addCallbackBuffers(camera);
}
Program: 24952
Project: 24952
Buggy source:
@Override public void onAutoFocus(boolean success,Camera camera){
  Message msg=mHandler.obtainMessage(PreviewHandler.AUTOFOCUS_MESSAGE,camera);
  if (success)   mHandler.sendMessageDelayed(msg,PreviewHandler.ALLOWABLE_FOCUS_TIME);
 else   mHandler.sendMessage(msg);
}

Fixed version (ground truth):
@Override public void onAutoFocus(boolean success,Camera camera){
  DebugOut.log("String_Node_Str");
  Message msg=mHandler.obtainMessage(PreviewHandler.AUTOFOCUS_MESSAGE,camera);
  if (success)   mHandler.sendMessageDelayed(msg,PreviewHandler.ALLOWABLE_FOCUS_TIME);
 else   mHandler.sendMessage(msg);
}
Program: 24953
Project: 24953
Buggy source:
@Override public void onPreviewFrame(byte[] data,Camera camera){
  if (mNeedAutoFocus) {
    camera.autoFocus(mCameraAutofocusCallback);
    mNeedAutoFocus=false;
  }
  if (mFrameEvaluator != null) {
    mFrameEvaluator.evaluate(data);
  }
  if (mFrameCount++ == NUMBER_PREVIEW_BUFFERS - 1) {
    mFrameCount=0;
    Message msg=mHandler.obtainMessage(PreviewHandler.ADD_BUFFERS_MESSAGE,camera);
    mHandler.sendMessageDelayed(msg,ADD_BUFFERS_SLACKTIME);
  }
}

Fixed version (ground truth):
@Override public void onPreviewFrame(byte[] data,Camera camera){
  DebugOut.log("String_Node_Str");
  if (mNeedAutoFocus) {
    camera.autoFocus(mCameraAutofocusCallback);
    mNeedAutoFocus=false;
  }
  if (mFrameCount++ == NUMBER_PREVIEW_BUFFERS - 1) {
    mFrameCount=0;
    Message msg=mHandler.obtainMessage(PreviewHandler.ADD_BUFFERS_MESSAGE,camera);
    mHandler.sendMessageDelayed(msg,ADD_BUFFERS_SLACKTIME);
  }
}
Program: 24954
Project: 24954
Buggy source:
@Override public void stop(Camera camera){
  mPreviewHandler.stopPreview(camera);
  mStateChanger.setState(new CameraReady());
}

Fixed version (ground truth):
@Override public void stop(Camera camera,CameraContext context){
  mPreviewHandler.stopPreview(camera);
  context.changeState(new CameraReady());
}
Program: 24955
Project: 24955
Buggy source:
public CameraPreviewing(Camera camera,SurfaceHolder holder,IFrameEvaluator evaluator) throws IOException {
  mPreviewHandler=new PreviewHandler(evaluator,camera);
  camera.setPreviewDisplay(holder);
  mPreviewHandler.startPreview(camera);
}

Fixed version (ground truth):
public CameraPreviewing(Camera camera,SurfaceHolder holder) throws IOException {
  mPreviewHandler=new PreviewHandler(camera);
  camera.setPreviewDisplay(holder);
  mPreviewHandler.startPreview(camera);
}
Program: 24956
Project: 24956
Buggy source:
@Override public void close(Camera camera){
  mPreviewHandler.stopPreview(camera);
  camera.release();
  mStateChanger.setState(new CameraUninitialized());
}

Fixed version (ground truth):
@Override public void close(Camera camera,CameraContext context){
  mPreviewHandler.stopPreview(camera);
  camera.release();
  context.changeState(new CameraUninitialized());
}
Program: 24957
Project: 24957
Buggy source:
@Override public void switchToPortrait(Camera camera){
  camera.setDisplayOrientation(90);
}

Fixed version (ground truth):
@Override public void switchToPortrait(Camera camera,CameraContext context){
  camera.setDisplayOrientation(90);
}
Program: 24958
Project: 24958
Buggy source:
@Override public void start(IFrameEvaluator evaluator,Camera camera,SurfaceHolder holder){
  try {
    CameraPreviewing previewingState=new CameraPreviewing(camera,holder,evaluator);
    camera.startPreview();
    mStateChanger.setState(previewingState);
  }
 catch (  IOException e) {
    e.printStackTrace();
    camera.release();
    mStateChanger.setState(new CameraUninitialized());
  }
}

Fixed version (ground truth):
@Override public void start(Camera camera,SurfaceHolder holder,CameraContext context){
  try {
    CameraPreviewing previewingState=new CameraPreviewing(camera,holder);
    camera.startPreview();
    context.changeState(previewingState);
  }
 catch (  IOException e) {
    e.printStackTrace();
    camera.release();
    context.changeState(new CameraUninitialized());
  }
}
Program: 24959
Project: 24959
Buggy source:
@Override public void close(Camera camera){
  camera.release();
  mStateChanger.setState(new CameraUninitialized());
}

Fixed version (ground truth):
@Override public void close(Camera camera,CameraContext context){
  camera.release();
  context.changeState(new CameraUninitialized());
}
Program: 24960
Project: 24960
Buggy source:
/** 
 * Helper that date/time setter callbacks use to update the sdnv and representations. 
 */
protected void setSdnvFromTime(Time time){
  long newValue=dtnUtil.DateToDtnShortDate(new Date(time.toMillis(false)));
  sdnv.setByValue(newValue);
  update(Type.DATE);
  updateDatesFromNumbers();
}

Fixed version (ground truth):
/** 
 * Helper that date/time setter callbacks use to update the sdnv and representations. 
 */
protected void setSdnvFromTime(Time time){
  long newValue=dtnUtil.DateToDtnShortDate(new Date(time.toMillis(false)));
  try {
    sdnv.setByValue(newValue);
  }
 catch (  NumberFormatException e) {
  }
  update(Type.DATE);
  updateDatesFromNumbers();
}
Program: 24962
Project: 24962
Buggy source:
private void bytesIntToBytes(){
  byte[] ba=bytesInt.toByteArray();
  int numZeros=0;
  for (numZeros=0; ba[numZeros] == 0x00; numZeros++)   ;
  bytes=new byte[ba.length - numZeros];
  System.arraycopy(ba,numZeros,bytes,0,ba.length - numZeros);
}

Fixed version (ground truth):
private void bytesIntToBytes(){
  byte[] ba=bytesInt.toByteArray();
  if (ba.length == 1 && ba[0] == 0x00) {
    bytes=ba;
    return;
  }
  int numZeros;
  for (numZeros=0; ba[numZeros] == 0x00; numZeros++)   ;
  bytes=new byte[ba.length - numZeros];
  System.arraycopy(ba,numZeros,bytes,0,ba.length - numZeros);
}
Program: 24963
Project: 24963
Buggy source:
private void bytesIntToBytes(){
  byte[] ba=bytesInt.toByteArray();
  int numZeros;
  for (numZeros=0; ba[numZeros] == 0x00; numZeros++)   ;
  bytes=new byte[ba.length - numZeros];
  System.arraycopy(ba,numZeros,bytes,0,ba.length - numZeros);
}

Fixed version (ground truth):
private void bytesIntToBytes(){
  byte[] ba=bytesInt.toByteArray();
  if (ba.length == 1 && ba[0] == 0x00) {
    bytes=ba;
    return;
  }
  int numZeros;
  for (numZeros=0; ba[numZeros] == 0x00; numZeros++)   ;
  bytes=new byte[ba.length - numZeros];
  System.arraycopy(ba,numZeros,bytes,0,ba.length - numZeros);
}
Program: 24964
Project: 24964
Buggy source:
public void handleMessage(Message msg){
switch (msg.what) {
case TorServiceConstants.STATUS_MSG:
    String torServiceMsg=(String)msg.getData().getString(HANDLER_TOR_MSG);
  if (lastServiceMsg == null || !lastServiceMsg.equals(torServiceMsg)) {
    updateStatus(torServiceMsg);
    lastServiceMsg=torServiceMsg;
  }
break;
case TorServiceConstants.LOG_MSG:
break;
case TorServiceConstants.ENABLE_TOR_MSG:
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
break;
case TorServiceConstants.DISABLE_TOR_MSG:
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
break;
case TorServiceConstants.MESSAGE_TRAFFIC_COUNT:
Bundle data=msg.getData();
DataCount datacount=new DataCount(data.getLong("String_Node_Str"),data.getLong("String_Node_Str"));
downloadText.setText(formatCount(datacount.Download));
uploadText.setText(formatCount(datacount.Upload));
downloadText.invalidate();
uploadText.invalidate();
break;
default :
super.handleMessage(msg);
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
switch (msg.what) {
case TorServiceConstants.STATUS_MSG:
    String torServiceMsg=(String)msg.getData().getString(HANDLER_TOR_MSG);
  if (lastServiceMsg == null || !lastServiceMsg.equals(torServiceMsg)) {
    updateStatus(torServiceMsg);
    lastServiceMsg=torServiceMsg;
  }
break;
case TorServiceConstants.LOG_MSG:
break;
case TorServiceConstants.ENABLE_TOR_MSG:
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
break;
case TorServiceConstants.DISABLE_TOR_MSG:
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
break;
case TorServiceConstants.MESSAGE_TRAFFIC_COUNT:
trafficRow.setVisibility(RelativeLayout.VISIBLE);
Bundle data=msg.getData();
DataCount datacount=new DataCount(data.getLong("String_Node_Str"),data.getLong("String_Node_Str"));
downloadText.setText(formatCount(datacount.Download));
uploadText.setText(formatCount(datacount.Upload));
downloadText.invalidate();
uploadText.invalidate();
break;
default :
super.handleMessage(msg);
}
}
Program: 24965
Project: 24965
Buggy source:
private void startTor() throws RemoteException {
  mService.setProfile(TorServiceConstants.PROFILE_ON);
  imgStatus.setImageResource(R.drawable.torstarting);
  lblStatus.setText(getString(R.string.status_starting_up));
  Message msg=mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
  msg.getData().putString(HANDLER_TOR_MSG,getString(R.string.status_starting_up));
  mHandler.sendMessage(msg);
  trafficRow.setVisibility(RelativeLayout.VISIBLE);
}

Fixed version (ground truth):
private void startTor() throws RemoteException {
  mService.setProfile(TorServiceConstants.PROFILE_ON);
  imgStatus.setImageResource(R.drawable.torstarting);
  lblStatus.setText(getString(R.string.status_starting_up));
  Message msg=mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
  msg.getData().putString(HANDLER_TOR_MSG,getString(R.string.status_starting_up));
  mHandler.sendMessage(msg);
}
Program: 24966
Project: 24966
Buggy source:
public void run(){
  if (currentStatus == STATUS_CONNECTING) {
    boolean isRunning=_torInstance.findExistingProc();
    if (!isRunning) {
      try {
        initTor();
        isRunning=true;
      }
 catch (      Exception e) {
        currentStatus=STATUS_OFF;
        this.showToolbarNotification(getString(R.string.status_disabled),ERROR_NOTIFY_ID,R.drawable.tornotificationerr,-1);
        Log.d(TAG,"String_Node_Str" + e.getMessage(),e);
      }
    }
  }
 else   if (currentStatus == STATUS_OFF) {
    _torInstance.stopTor();
  }
}

Fixed version (ground truth):
public void run(){
  findExistingProc();
}
Program: 24967
Project: 24967
Buggy source:
public IBinder onBind(Intent intent){
  _torInstance=this;
  initTorPaths();
  findExistingProc();
  if (ITorService.class.getName().equals(intent.getAction())) {
    return mBinder;
  }
 else   return null;
}

Fixed version (ground truth):
public IBinder onBind(Intent intent){
  _torInstance=this;
  initTorPaths();
  new Thread(){
    public void run(){
      findExistingProc();
    }
  }
.start();
  if (ITorService.class.getName().equals(intent.getAction())) {
    return mBinder;
  }
 else   return null;
}
Program: 24968
Project: 24968
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction() != null && intent.getAction().equals("String_Node_Str")) {
    Intent service=new Intent();
    service.setAction("String_Node_Str");
    service.setClass(context,TorService.class);
    context.startService(service);
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction() != null && intent.getAction().equals("String_Node_Str")) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
    boolean startOnBoot=prefs.getBoolean("String_Node_Str",false);
    if (startOnBoot) {
      Intent service=new Intent();
      service.setAction("String_Node_Str");
      service.setClass(context,TorService.class);
      context.startService(service);
    }
  }
}
Program: 24969
Project: 24969
Buggy source:
public void onStart(Intent intent,int startId){
  super.onStart(intent,startId);
  _torInstance=this;
  initTorPaths();
  new Thread(){
    public void run(){
      try {
        checkTorBinaries(false);
      }
 catch (      Exception e) {
        logNotice("String_Node_Str" + e.getMessage());
        showToolbarNotification(getString(R.string.error_installing_binares),ERROR_NOTIFY_ID,R.drawable.tornotificationerr,-1);
        Log.e(TAG,"String_Node_Str",e);
      }
    }
  }
.start();
  if (intent.getAction() != null && intent.getAction().equals("String_Node_Str")) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    boolean startOnBoot=prefs.getBoolean("String_Node_Str",false);
    if (startOnBoot) {
      setTorProfile(PROFILE_ON);
    }
  }
}

Fixed version (ground truth):
public void onStart(Intent intent,int startId){
  super.onStart(intent,startId);
  _torInstance=this;
  initTorPaths();
  new Thread(){
    public void run(){
      try {
        checkTorBinaries(false);
      }
 catch (      Exception e) {
        logNotice("String_Node_Str" + e.getMessage());
        showToolbarNotification(getString(R.string.error_installing_binares),ERROR_NOTIFY_ID,R.drawable.tornotificationerr,-1);
        Log.e(TAG,"String_Node_Str",e);
      }
    }
  }
.start();
  if (intent != null && intent.getAction() != null && intent.getAction().equals("String_Node_Str")) {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    boolean startOnBoot=prefs.getBoolean("String_Node_Str",false);
    if (startOnBoot) {
      setTorProfile(PROFILE_ON);
    }
  }
}
Program: 24971
Project: 24971
Buggy source:
private void hideProgressDialog(){
  if (progressDialog != null && progressDialog.isShowing()) {
    progressDialog.dismiss();
  }
}

Fixed version (ground truth):
private void hideProgressDialog(){
  if (progressDialog != null && progressDialog.isShowing()) {
    progressDialog.dismiss();
    progressDialog=null;
  }
}
Program: 24972
Project: 24972
Buggy source:
private void startTor() throws RemoteException {
  bindService();
  mService.setProfile(TorServiceConstants.PROFILE_ON);
  imgStatus.setImageResource(R.drawable.torstarting);
  lblStatus.setText(getString(R.string.status_starting_up));
  Message msg=mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
  mHandler.sendMessage(msg);
}

Fixed version (ground truth):
private void startTor() throws RemoteException {
  bindService();
  mService.setProfile(TorServiceConstants.PROFILE_ON);
  imgStatus.setImageResource(R.drawable.torstarting);
  lblStatus.setText(getString(R.string.status_starting_up));
  Message msg=mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
  msg.getData().putString(HANDLER_TOR_MSG,getString(R.string.status_starting_up));
  mHandler.sendMessage(msg);
}
Program: 24973
Project: 24973
Buggy source:
private void createProgressDialog(String msg){
  if (progressDialog != null && progressDialog.isShowing())   return;
  progressDialog=ProgressDialog.show(Orbot.this,"String_Node_Str",msg);
  progressDialog.setCancelable(true);
}

Fixed version (ground truth):
private void createProgressDialog(String msg){
  if (progressDialog != null && progressDialog.isShowing()) {
    progressDialog.setMessage(msg);
  }
 else {
    progressDialog=ProgressDialog.show(Orbot.this,"String_Node_Str",msg);
    progressDialog.setCancelable(true);
  }
}
Program: 24974
Project: 24974
Buggy source:
private void showAlert(String title,String msg,boolean button){
  try {
    if (aDialog != null && aDialog.isShowing())     aDialog.dismiss();
  }
 catch (  Exception e) {
  }
  if (button) {
    aDialog=new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).setPositiveButton(android.R.string.ok,null).show();
  }
 else {
    aDialog=new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).show();
  }
  aDialog.setCanceledOnTouchOutside(true);
}

Fixed version (ground truth):
private void showAlert(String title,String msg,boolean button){
  try {
    if (aDialog != null && aDialog.isShowing())     aDialog.dismiss();
  }
 catch (  Exception e) {
  }
  if (button) {
    aDialog=new AlertDialog.Builder(Orbot.this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).setPositiveButton(android.R.string.ok,null).show();
  }
 else {
    aDialog=new AlertDialog.Builder(Orbot.this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).show();
  }
  aDialog.setCanceledOnTouchOutside(true);
}
Program: 24975
Project: 24975
Buggy source:
private void installFromRaw(){
  InputStream is=context.getResources().openRawResource(R.raw.toraa);
  streamToFile(is,installPath + TOR_BINARY_ASSET_KEY,false);
  is=context.getResources().openRawResource(R.raw.torab);
  streamToFile(is,installPath + TOR_BINARY_ASSET_KEY,true);
  is=context.getResources().openRawResource(R.raw.torac);
  streamToFile(is,installPath + TOR_BINARY_ASSET_KEY,true);
  is=context.getResources().openRawResource(R.raw.torad);
  streamToFile(is,installPath + TOR_BINARY_ASSET_KEY,true);
  is=context.getResources().openRawResource(R.raw.torrc);
  streamToFile(is,installPath + TORRC_ASSET_KEY,false);
  is=context.getResources().openRawResource(R.raw.privoxy);
  streamToFile(is,installPath + PRIVOXY_ASSET_KEY,false);
  is=context.getResources().openRawResource(R.raw.privoxy_config);
  streamToFile(is,installPath + PRIVOXYCONFIG_ASSET_KEY,false);
  Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
public boolean installFromRaw(){
  boolean result=false;
  try {
    InputStream is;
    is=context.getResources().openRawResource(R.raw.toraa);
    streamToFile(is,installFolder,TOR_BINARY_ASSET_KEY,false);
    is=context.getResources().openRawResource(R.raw.torab);
    streamToFile(is,installFolder,TOR_BINARY_ASSET_KEY,true);
    is=context.getResources().openRawResource(R.raw.torac);
    streamToFile(is,installFolder,TOR_BINARY_ASSET_KEY,true);
    is=context.getResources().openRawResource(R.raw.torad);
    streamToFile(is,installFolder,TOR_BINARY_ASSET_KEY,true);
    is=context.getResources().openRawResource(R.raw.torrc);
    streamToFile(is,installFolder,TORRC_ASSET_KEY,false);
    is=context.getResources().openRawResource(R.raw.privoxy);
    streamToFile(is,installFolder,PRIVOXY_ASSET_KEY,false);
    is=context.getResources().openRawResource(R.raw.privoxy_config);
    streamToFile(is,installFolder,PRIVOXYCONFIG_ASSET_KEY,false);
  }
 catch (  IOException ioe) {
    Log.e(TAG,"String_Node_Str",ioe);
    return false;
  }
  return true;
}
Program: 24976
Project: 24976
Buggy source:
private static void streamToFile(InputStream stm,String targetFilename,boolean append){
  FileOutputStream stmOut=null;
  byte[] buffer=new byte[FILE_WRITE_BUFFER_SIZE];
  int bytecount;
  File outFile=new File(targetFilename);
  try {
    if (!append)     outFile.createNewFile();
    stmOut=new FileOutputStream(outFile);
  }
 catch (  java.io.IOException e) {
    Log.d(TAG,"String_Node_Str" + targetFilename,e);
    return;
  }
  try {
    while ((bytecount=stm.read(buffer)) > 0) {
      stmOut.write(buffer,0,bytecount);
    }
    stmOut.close();
  }
 catch (  java.io.IOException e) {
    Log.d(TAG,"String_Node_Str" + targetFilename + "String_Node_Str"+ e.toString());
    return;
  }
}

Fixed version (ground truth):
private static boolean streamToFile(InputStream stm,File folder,String targetFilename,boolean append) throws IOException {
  byte[] buffer=new byte[FILE_WRITE_BUFFER_SIZE];
  int bytecount;
  File outFile=new File(folder,targetFilename);
  FileOutputStream stmOut=new FileOutputStream(outFile,append);
  while ((bytecount=stm.read(buffer)) > 0) {
    stmOut.write(buffer,0,bytecount);
  }
  stmOut.close();
  return true;
}
Program: 24977
Project: 24977
Buggy source:
public TorBinaryInstaller(Context context,String installPath,String apkPath){
  this.installPath=installPath;
  this.apkPath=apkPath;
  this.context=context;
}

Fixed version (ground truth):
public TorBinaryInstaller(Context context,File installFolder){
  this.installFolder=installFolder;
  this.context=context;
}
Program: 24978
Project: 24978
Buggy source:
private void runTorShellCmd() throws Exception {
  StringBuilder log=new StringBuilder();
  String torrcPath=appBinHome + TORRC_ASSET_KEY;
  String[] torCmd={torBinaryPath + "String_Node_Str" + appDataHome+ "String_Node_Str"+ torrcPath+ "String_Node_Str"};
  boolean runAsRootFalse=false;
  boolean waitForProcess=false;
  int procId=-1;
  int attempts=0;
  int torRetryWaitTimeMS=5000;
  while (procId == -1 && attempts < MAX_START_TRIES) {
    log=new StringBuilder();
    logNotice(torCmd[0]);
    sendCallbackStatusMessage(getString(R.string.status_starting_up));
    TorServiceUtils.doShellCommand(torCmd,log,runAsRootFalse,waitForProcess);
    Thread.sleep(torRetryWaitTimeMS);
    procId=TorServiceUtils.findProcessId(torBinaryPath);
    logNotice("String_Node_Str" + procId);
    if (procId == -1) {
      sendCallbackStatusMessage("String_Node_Str" + log.toString());
      Thread.sleep(torRetryWaitTimeMS);
      attempts++;
    }
    logNotice(log.toString());
  }
  if (procId == -1) {
    throw new Exception("String_Node_Str");
  }
 else {
    logNotice("String_Node_Str" + procId);
    showToolbarNotification(getString(R.string.status_starting_up),NOTIFY_ID,R.drawable.tornotification);
    initControlConnection();
    applyPreferences();
  }
}

Fixed version (ground truth):
private void runTorShellCmd() throws Exception {
  StringBuilder log=new StringBuilder();
  String torrcPath=new File(appBinHome,TORRC_ASSET_KEY).getAbsolutePath();
  String[] torCmd={torBinaryPath + "String_Node_Str" + appDataHome.getAbsolutePath()+ "String_Node_Str"+ torrcPath+ "String_Node_Str"};
  boolean runAsRootFalse=false;
  boolean waitForProcess=false;
  int procId=-1;
  int attempts=0;
  int torRetryWaitTimeMS=5000;
  while (procId == -1 && attempts < MAX_START_TRIES) {
    log=new StringBuilder();
    logNotice(torCmd[0]);
    sendCallbackStatusMessage(getString(R.string.status_starting_up));
    TorServiceUtils.doShellCommand(torCmd,log,runAsRootFalse,waitForProcess);
    Thread.sleep(torRetryWaitTimeMS);
    procId=TorServiceUtils.findProcessId(torBinaryPath);
    logNotice("String_Node_Str" + procId);
    if (procId == -1) {
      sendCallbackStatusMessage("String_Node_Str" + log.toString());
      Thread.sleep(torRetryWaitTimeMS);
      attempts++;
    }
    logNotice(log.toString());
  }
  if (procId == -1) {
    throw new Exception("String_Node_Str");
  }
 else {
    logNotice("String_Node_Str" + procId);
    showToolbarNotification(getString(R.string.status_starting_up),NOTIFY_ID,R.drawable.tornotification);
    initControlConnection();
    applyPreferences();
  }
}
Program: 24979
Project: 24979
Buggy source:
private void runPrivoxyShellCmd() throws Exception {
  logNotice("String_Node_Str");
  int privoxyProcId=TorServiceUtils.findProcessId(privoxyPath);
  StringBuilder log=null;
  int attempts=0;
  if (privoxyProcId == -1) {
    log=new StringBuilder();
    String privoxyConfigPath=appBinHome + PRIVOXYCONFIG_ASSET_KEY;
    String[] cmds={privoxyPath + "String_Node_Str" + privoxyConfigPath+ "String_Node_Str"};
    logNotice(cmds[0]);
    boolean runAsRoot=false;
    boolean waitFor=false;
    TorServiceUtils.doShellCommand(cmds,log,runAsRoot,waitFor);
    Thread.sleep(1000);
    while ((privoxyProcId=TorServiceUtils.findProcessId(privoxyPath)) == -1 && attempts < MAX_START_TRIES) {
      logNotice("String_Node_Str" + log);
      Thread.sleep(3000);
      attempts++;
    }
    logNotice(log.toString());
  }
  sendCallbackLogMessage("String_Node_Str" + PORT_HTTP);
  logNotice("String_Node_Str" + privoxyProcId);
}

Fixed version (ground truth):
private void runPrivoxyShellCmd() throws Exception {
  logNotice("String_Node_Str");
  int privoxyProcId=TorServiceUtils.findProcessId(privoxyPath);
  StringBuilder log=null;
  int attempts=0;
  if (privoxyProcId == -1) {
    log=new StringBuilder();
    String privoxyConfigPath=new File(appBinHome,PRIVOXYCONFIG_ASSET_KEY).getAbsolutePath();
    String[] cmds={privoxyPath + "String_Node_Str" + privoxyConfigPath+ "String_Node_Str"};
    logNotice(cmds[0]);
    boolean runAsRoot=false;
    boolean waitFor=false;
    TorServiceUtils.doShellCommand(cmds,log,runAsRoot,waitFor);
    Thread.sleep(1000);
    while ((privoxyProcId=TorServiceUtils.findProcessId(privoxyPath)) == -1 && attempts < MAX_START_TRIES) {
      logNotice("String_Node_Str" + log);
      Thread.sleep(3000);
      attempts++;
    }
    logNotice(log.toString());
  }
  sendCallbackLogMessage("String_Node_Str" + PORT_HTTP);
  logNotice("String_Node_Str" + privoxyProcId);
}
Program: 24980
Project: 24980
Buggy source:
public void initControlConnection() throws Exception, RuntimeException {
  while (true) {
    try {
      logNotice("String_Node_Str" + TOR_CONTROL_PORT);
      String baseMessage=getString(R.string.tor_process_connecting);
      sendCallbackStatusMessage(baseMessage);
      torConnSocket=new Socket(IP_LOCALHOST,TOR_CONTROL_PORT);
      conn=TorControlConnection.getConnection(torConnSocket);
      sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2));
      logNotice("String_Node_Str");
      String torAuthCookie=appDataHome + TOR_CONTROL_COOKIE;
      File fileCookie=new File(torAuthCookie);
      if (fileCookie.exists()) {
        byte[] cookie=new byte[(int)fileCookie.length()];
        new FileInputStream(new File(torAuthCookie)).read(cookie);
        conn.authenticate(cookie);
        logNotice("String_Node_Str");
        sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2) + getString(R.string.tor_process_connecting_step3));
        addEventHandler();
      }
      break;
    }
 catch (    Exception ce) {
      conn=null;
      Log.d(TAG,"String_Node_Str" + ce.getLocalizedMessage(),ce);
      sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step4));
      Thread.sleep(1000);
    }
  }
}

Fixed version (ground truth):
public void initControlConnection() throws Exception, RuntimeException {
  while (true) {
    try {
      logNotice("String_Node_Str" + TOR_CONTROL_PORT);
      String baseMessage=getString(R.string.tor_process_connecting);
      sendCallbackStatusMessage(baseMessage);
      torConnSocket=new Socket(IP_LOCALHOST,TOR_CONTROL_PORT);
      conn=TorControlConnection.getConnection(torConnSocket);
      sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2));
      logNotice("String_Node_Str");
      String torAuthCookie=new File(appDataHome,TOR_CONTROL_COOKIE).getAbsolutePath();
      File fileCookie=new File(torAuthCookie);
      if (fileCookie.exists()) {
        byte[] cookie=new byte[(int)fileCookie.length()];
        new FileInputStream(new File(torAuthCookie)).read(cookie);
        conn.authenticate(cookie);
        logNotice("String_Node_Str");
        sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2) + getString(R.string.tor_process_connecting_step3));
        addEventHandler();
      }
      break;
    }
 catch (    Exception ce) {
      conn=null;
      Log.d(TAG,"String_Node_Str" + ce.getLocalizedMessage(),ce);
      sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step4));
      Thread.sleep(1000);
    }
  }
}
Program: 24983
Project: 24983
Buggy source:
protected void onPause(){
  super.onPause();
}

Fixed version (ground truth):
protected void onPause(){
  super.onPause();
  if (progressDialog != null) {
    progressDialog.dismiss();
    progressDialog=null;
  }
}
Program: 24984
Project: 24984
Buggy source:
private void showAlert(String title,String msg,boolean button){
  if (aDialog != null)   aDialog.dismiss();
  if (button) {
    aDialog=new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).setPositiveButton(android.R.string.ok,null).show();
  }
 else {
    aDialog=new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).show();
  }
}

Fixed version (ground truth):
private void showAlert(String title,String msg,boolean button){
  AlertDialog aDialog=null;
  if (button) {
    aDialog=new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).setPositiveButton(android.R.string.ok,null).show();
  }
 else {
    aDialog=new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle(title).setMessage(msg).show();
  }
}
Program: 24985
Project: 24985
Buggy source:
@Override public boolean onPreferenceClick(Preference preference){
  if (preference == prefTransProxyApps) {
    startActivity(new Intent(this,AppManager.class));
  }
 else {
    prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
    prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onPreferenceClick(Preference preference){
  if (preference == prefTransProxyApps) {
    startActivity(new Intent(this,AppManager.class));
  }
 else   if (preference == prefWebProxy) {
    Intent intent=new Intent();
    intent.setClassName(this,"String_Node_Str");
    intent.putExtra("String_Node_Str","String_Node_Str");
    intent.putExtra("String_Node_Str","String_Node_Str");
    startActivity(intent);
  }
 else {
    prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
    prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
  }
  return true;
}
Program: 24986
Project: 24986
Buggy source:
public void initControlConnection() throws Exception, RuntimeException {
  while (true) {
    try {
      Log.i(TAG,"String_Node_Str" + TOR_CONTROL_PORT);
      String baseMessage=getString(R.string.tor_process_connecting);
      sendCallbackMessage(baseMessage);
      Socket s=new Socket(IP_LOCALHOST,TOR_CONTROL_PORT);
      conn=TorControlConnection.getConnection(s);
      sendCallbackMessage(getString(R.string.tor_process_connecting_step2));
      Log.i(TAG,"String_Node_Str");
      String torAuthCookie=appHome + "String_Node_Str";
      File fileCookie=new File(torAuthCookie);
      byte[] cookie=new byte[(int)fileCookie.length()];
      new FileInputStream(new File(torAuthCookie)).read(cookie);
      conn.authenticate(cookie);
      Log.i(TAG,"String_Node_Str");
      sendCallbackMessage(getString(R.string.tor_process_connecting_step2) + getString(R.string.tor_process_connecting_step3));
      addEventHandler();
      if (configBuffer != null) {
        conn.setConf(configBuffer);
        configBuffer=null;
      }
      break;
    }
 catch (    Exception ce) {
      conn=null;
      Log.i(TAG,"String_Node_Str" + ce.getLocalizedMessage(),ce);
      sendCallbackMessage(getString(R.string.tor_process_connecting_step4));
      Thread.sleep(1000);
    }
  }
}

Fixed version (ground truth):
public void initControlConnection() throws Exception, RuntimeException {
  while (true) {
    try {
      Log.i(TAG,"String_Node_Str" + TOR_CONTROL_PORT);
      String baseMessage=getString(R.string.tor_process_connecting);
      sendCallbackMessage(baseMessage);
      Socket s=new Socket(IP_LOCALHOST,TOR_CONTROL_PORT);
      conn=TorControlConnection.getConnection(s);
      sendCallbackMessage(getString(R.string.tor_process_connecting_step2));
      Log.i(TAG,"String_Node_Str");
      String torAuthCookie=appHome + "String_Node_Str";
      File fileCookie=new File(torAuthCookie);
      byte[] cookie=new byte[(int)fileCookie.length()];
      new FileInputStream(new File(torAuthCookie)).read(cookie);
      conn.authenticate(cookie);
      Log.i(TAG,"String_Node_Str");
      sendCallbackMessage(getString(R.string.tor_process_connecting_step2) + getString(R.string.tor_process_connecting_step3));
      addEventHandler();
      applyPreferences();
      break;
    }
 catch (    Exception ce) {
      conn=null;
      Log.i(TAG,"String_Node_Str" + ce.getLocalizedMessage(),ce);
      sendCallbackMessage(getString(R.string.tor_process_connecting_step4));
      Thread.sleep(1000);
    }
  }
}
Program: 24987
Project: 24987
Buggy source:
public boolean saveConfiguration(){
  try {
    if (conn != null) {
      return true;
    }
  }
 catch (  Exception ioe) {
    Log.e(TAG,"String_Node_Str",ioe);
    logNotice("String_Node_Str" + ioe.getMessage());
  }
  return false;
}

Fixed version (ground truth):
public boolean saveConfiguration(){
  try {
    if (conn != null) {
      if (configBuffer != null) {
        conn.setConf(configBuffer);
        configBuffer=null;
      }
      return true;
    }
  }
 catch (  Exception ioe) {
    Log.e(TAG,"String_Node_Str",ioe);
    logNotice("String_Node_Str" + ioe.getMessage());
  }
  return false;
}
Program: 24988
Project: 24988
Buggy source:
/** 
 * Set configuration
 */
public boolean updateConfiguration(String name,String value,boolean saveToDisk){
  try {
    if (conn != null) {
      conn.setConf(name,value);
      if (saveToDisk) {
      }
      return true;
    }
 else {
      if (configBuffer == null)       configBuffer=new ArrayList<String>();
      configBuffer.add(name + ' ' + value);
    }
  }
 catch (  IOException ioe) {
    Log.e(TAG,"String_Node_Str",ioe);
    logNotice("String_Node_Str" + ioe.getMessage());
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Set configuration
 */
public boolean updateConfiguration(String name,String value,boolean saveToDisk){
  if (configBuffer == null)   configBuffer=new ArrayList<String>();
  configBuffer.add(name + ' ' + value);
  return false;
}