Program: 32396
Project: 32396
Buggy source:
/** 
 * Closes the USB connection from inside the transport with some extra info.
 * @param msg Disconnect reason message, if any
 * @param ex  Disconnect exception, if any
 */
private void disconnect(String msg,Exception ex){
  final State state=getState();
switch (state) {
case LISTENING:
case CONNECTED:
synchronized (this) {
      logI("String_Node_Str" + getState() + "String_Node_Str"+ msg+ "String_Node_Str"+ ex);
      setState(State.IDLE);
      SdlTrace.logTransportEvent(TAG + "String_Node_Str",null,InterfaceActivityDirection.None,null,0,SDL_LIB_TRACE_KEY);
      stopReaderThread();
      if (mAccessory != null) {
        if (mOutputStream != null) {
          try {
            mOutputStream.close();
          }
 catch (          IOException e) {
            logW("String_Node_Str",e);
            mOutputStream=null;
          }
        }
        if (mInputStream != null) {
          try {
            mInputStream.close();
          }
 catch (          IOException e) {
            logW("String_Node_Str",e);
            mInputStream=null;
          }
        }
        if (mParcelFD != null) {
          try {
            mParcelFD.close();
          }
 catch (          IOException e) {
            logW("String_Node_Str",e);
            mParcelFD=null;
          }
        }
        mAccessory=null;
      }
    }
  logD("String_Node_Str");
try {
  getContext().unregisterReceiver(mUSBReceiver);
}
 catch (IllegalArgumentException e) {
  logW("String_Node_Str",e);
}
String disconnectMsg=(msg == null ? "String_Node_Str" : msg);
if (ex != null) {
disconnectMsg+="String_Node_Str" + ex.toString();
}
if (ex == null) {
logI("String_Node_Str");
handleTransportDisconnected(disconnectMsg);
}
 else {
logI("String_Node_Str");
handleTransportError(disconnectMsg,ex);
}
break;
default :
logW("String_Node_Str" + state + "String_Node_Str");
break;
}
}

Fixed version (ground truth):
/** 
 * Closes the USB connection from inside the transport with some extra info.
 * @param msg Disconnect reason message, if any
 * @param ex  Disconnect exception, if any
 */
private void disconnect(String msg,Exception ex){
  if (_disconnecting) {
    return;
  }
  _disconnecting=true;
  final State state=getState();
switch (state) {
case LISTENING:
case CONNECTED:
synchronized (this) {
      logI("String_Node_Str" + getState() + "String_Node_Str"+ msg+ "String_Node_Str"+ ex);
      setState(State.IDLE);
      SdlTrace.logTransportEvent(TAG + "String_Node_Str",null,InterfaceActivityDirection.None,null,0,SDL_LIB_TRACE_KEY);
      stopReaderThread();
      if (mAccessory != null) {
        if (mOutputStream != null) {
          try {
            mOutputStream.close();
            mOutputStream=null;
          }
 catch (          IOException e) {
            logW("String_Node_Str",e);
            mOutputStream=null;
          }
        }
        if (mInputStream != null) {
          try {
            mInputStream.close();
            mInputStream=null;
          }
 catch (          IOException e) {
            logW("String_Node_Str",e);
            mInputStream=null;
          }
        }
        if (mParcelFD != null) {
          try {
            mParcelFD.close();
            mParcelFD=null;
          }
 catch (          IOException e) {
            logW("String_Node_Str",e);
            mParcelFD=null;
          }
        }
        mAccessory=null;
      }
    }
  logD("String_Node_Str");
try {
  getContext().unregisterReceiver(mUSBReceiver);
}
 catch (IllegalArgumentException e) {
  logW("String_Node_Str",e);
}
String disconnectMsg=(msg == null ? "String_Node_Str" : msg);
if (ex != null) {
disconnectMsg+="String_Node_Str" + ex.toString();
}
if (ex == null) {
logI("String_Node_Str");
handleTransportDisconnected(disconnectMsg);
}
 else {
logI("String_Node_Str");
handleTransportError(disconnectMsg,ex);
}
break;
default :
logW("String_Node_Str" + state + "String_Node_Str");
break;
}
_disconnecting=false;
}