Program: 32229
Project: 32229
Buggy source:
/** 
 * Destroys the transport between SDL and the mobile app
 * @param msg
 * @param ex
 */
private synchronized void disconnect(String msg,Exception ex){
  if (_disconnecting) {
    return;
  }
  _disconnecting=true;
  String disconnectMsg=(msg == null ? "String_Node_Str" : msg);
  if (ex != null) {
    disconnectMsg+="String_Node_Str" + ex.toString();
  }
  SdlTrace.logTransportEvent("String_Node_Str" + disconnectMsg,null,InterfaceActivityDirection.Transmit,null,0,SDL_LIB_TRACE_KEY);
  try {
    if (_transportReader != null) {
      _transportReader.halt();
      _transportReader=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_bluetoothAdapterMonitor != null) {
      _bluetoothAdapterMonitor.halt();
      _bluetoothAdapterMonitor=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_serverSocket != null) {
      _serverSocket.close();
      _serverSocket=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_activeSocket != null) {
      _activeSocket.close();
      _activeSocket=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_output != null) {
      _output.close();
      _output=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  if (ex == null) {
    handleTransportDisconnected(msg);
  }
 else {
    handleTransportError(msg,ex);
  }
  _disconnecting=false;
}

Fixed version (ground truth):
/** 
 * Destroys the transport between SDL and the mobile app
 * @param msg
 * @param ex
 */
private void disconnect(String msg,Exception ex){
synchronized (DISCONNECT_LOCK) {
    if (_disconnecting) {
      return;
    }
    _disconnecting=true;
  }
  String disconnectMsg=(msg == null ? "String_Node_Str" : msg);
  if (ex != null) {
    disconnectMsg+="String_Node_Str" + ex.toString();
  }
  SdlTrace.logTransportEvent("String_Node_Str" + disconnectMsg,null,InterfaceActivityDirection.Transmit,null,0,SDL_LIB_TRACE_KEY);
  try {
    if (_transportReader != null) {
      _transportReader.halt();
      _transportReader=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_bluetoothAdapterMonitor != null) {
      _bluetoothAdapterMonitor.halt();
      _bluetoothAdapterMonitor=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_serverSocket != null) {
      _serverSocket.close();
      _serverSocket=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_activeSocket != null) {
      _activeSocket.close();
      _activeSocket=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  try {
    if (_output != null) {
      _output.close();
      _output=null;
    }
  }
 catch (  Exception e) {
    DebugTool.logError("String_Node_Str",e);
  }
  if (ex == null) {
    handleTransportDisconnected(msg);
  }
 else {
    handleTransportError(msg,ex);
  }
  _disconnecting=false;
}