Program: 84969
Project: 84969
Buggy source:
public void run(){
  if (Constants.LOGV) {
    Log.v(TAG,"String_Node_Str");
  }
  if (Constants.USE_TCP_DEBUG) {
    ServerSocket mServerSocket=null;
    try {
      if (Constants.LOGVV) {
        Log.v(TAG,"String_Node_Str" + Constants.TCP_DEBUG_PORT);
      }
      mServerSocket=new ServerSocket(Constants.TCP_DEBUG_PORT,1);
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str" + Constants.TCP_DEBUG_PORT);
      mInterrupted=true;
    }
    while (!mInterrupted) {
      try {
        mServerSocket.setSoTimeout(ACCEPT_WAIT_TIMEOUT);
        Socket clientSocket=mServerSocket.accept();
        if (clientSocket == null) {
          if (Constants.LOGVV) {
            Log.v(TAG,"String_Node_Str");
          }
        }
 else {
          if (Constants.LOGV) {
            Log.v(TAG,"String_Node_Str");
          }
          Log.d(TAG,"String_Node_Str" + clientSocket.getRemoteSocketAddress());
          TestTcpTransport transport=new TestTcpTransport(clientSocket);
          Message msg=Message.obtain();
          msg.setTarget(mCallback);
          msg.what=MSG_INCOMING_BTOPP_CONNECTION;
          msg.obj=transport;
          msg.sendToTarget();
        }
      }
 catch (      SocketException e) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + e);
        }
      }
catch (      IOException e) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + e);
        }
      }
    }
    if (Constants.LOGV) {
      Log.v(TAG,"String_Node_Str");
    }
    try {
      mServerSocket.close();
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str" + e);
    }
  }
 else {
    BluetoothServerSocket mServerSocket=null;
    boolean serverOK=true;
    if (Constants.LOGVV) {
      Log.v(TAG,"String_Node_Str" + mBtOppRfcommChannel);
    }
    for (int i=0; i < CREATE_RETRY_TIME && !mInterrupted; i++) {
      try {
        mServerSocket=BluetoothServerSocket.listenUsingInsecureRfcommOn(mBtOppRfcommChannel);
      }
 catch (      IOException e1) {
        Log.d(TAG,"String_Node_Str" + e1);
        serverOK=false;
      }
      if (!serverOK) {
synchronized (this) {
          try {
            if (Constants.LOGVV) {
              Log.v(TAG,"String_Node_Str");
            }
            Thread.sleep(3000);
          }
 catch (          InterruptedException e) {
            Log.e(TAG,"String_Node_Str");
            mInterrupted=true;
          }
        }
      }
 else {
        break;
      }
    }
    if (!serverOK) {
      Log.e(TAG,"String_Node_Str" + CREATE_RETRY_TIME + "String_Node_Str");
      mInterrupted=true;
    }
    BluetoothSocket clientSocket;
    while (!mInterrupted) {
      try {
        clientSocket=mServerSocket.accept(ACCEPT_WAIT_TIMEOUT);
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str");
          Log.v(TAG,"String_Node_Str" + clientSocket.getAddress());
        }
        BluetoothOppRfcommTransport transport=new BluetoothOppRfcommTransport(clientSocket);
        Message msg=Message.obtain();
        msg.setTarget(mCallback);
        msg.what=MSG_INCOMING_BTOPP_CONNECTION;
        msg.obj=transport;
        msg.sendToTarget();
      }
 catch (      IOException e) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + e);
        }
      }
    }
    try {
      if (mServerSocket != null) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str");
        }
        mServerSocket.close();
      }
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str" + e);
    }
    if (Constants.LOGV) {
      Log.v(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void run(){
  if (Constants.LOGV) {
    Log.v(TAG,"String_Node_Str");
  }
  if (Constants.USE_TCP_DEBUG) {
    ServerSocket mServerSocket=null;
    try {
      if (Constants.LOGVV) {
        Log.v(TAG,"String_Node_Str" + Constants.TCP_DEBUG_PORT);
      }
      mServerSocket=new ServerSocket(Constants.TCP_DEBUG_PORT,1);
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str" + Constants.TCP_DEBUG_PORT);
      mInterrupted=true;
    }
    while (!mInterrupted) {
      try {
        mServerSocket.setSoTimeout(ACCEPT_WAIT_TIMEOUT);
        Socket clientSocket=mServerSocket.accept();
        if (clientSocket == null) {
          if (Constants.LOGVV) {
            Log.v(TAG,"String_Node_Str");
          }
        }
 else {
          if (Constants.LOGV) {
            Log.v(TAG,"String_Node_Str");
          }
          Log.d(TAG,"String_Node_Str" + clientSocket.getRemoteSocketAddress());
          TestTcpTransport transport=new TestTcpTransport(clientSocket);
          Message msg=Message.obtain();
          msg.setTarget(mCallback);
          msg.what=MSG_INCOMING_BTOPP_CONNECTION;
          msg.obj=transport;
          msg.sendToTarget();
        }
      }
 catch (      SocketException e) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + e);
        }
      }
catch (      IOException e) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + e);
        }
      }
    }
    if (Constants.LOGV) {
      Log.v(TAG,"String_Node_Str");
    }
    try {
      mServerSocket.close();
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str" + e);
    }
  }
 else {
    BluetoothServerSocket mServerSocket=null;
    boolean serverOK=true;
    if (Constants.LOGVV) {
      Log.v(TAG,"String_Node_Str" + mBtOppRfcommChannel);
    }
    for (int i=0; i < CREATE_RETRY_TIME && !mInterrupted; i++) {
      try {
        mServerSocket=BluetoothServerSocket.listenUsingInsecureRfcommOn(mBtOppRfcommChannel);
      }
 catch (      IOException e1) {
        Log.d(TAG,"String_Node_Str" + e1);
        serverOK=false;
      }
      if (!serverOK) {
synchronized (this) {
          try {
            if (Constants.LOGVV) {
              Log.v(TAG,"String_Node_Str");
            }
            Thread.sleep(3000);
          }
 catch (          InterruptedException e) {
            Log.e(TAG,"String_Node_Str");
            mInterrupted=true;
          }
        }
      }
 else {
        break;
      }
    }
    if (!serverOK) {
      Log.e(TAG,"String_Node_Str" + CREATE_RETRY_TIME + "String_Node_Str");
      mInterrupted=true;
    }
    BluetoothSocket clientSocket;
    while (!mInterrupted) {
      try {
        clientSocket=mServerSocket.accept(ACCEPT_WAIT_TIMEOUT);
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str");
          Log.v(TAG,"String_Node_Str" + clientSocket.getAddress());
        }
        BluetoothOppRfcommTransport transport=new BluetoothOppRfcommTransport(clientSocket);
        Message msg=Message.obtain();
        msg.setTarget(mCallback);
        msg.what=MSG_INCOMING_BTOPP_CONNECTION;
        msg.obj=transport;
        msg.sendToTarget();
      }
 catch (      IOException e) {
        if (Constants.LOGVV) {
        }
      }
    }
    try {
      if (mServerSocket != null) {
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str");
        }
        mServerSocket.close();
      }
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str" + e);
    }
    if (Constants.LOGV) {
      Log.v(TAG,"String_Node_Str");
    }
  }
}