nus-yam/ex-repair huggingface dataset:
Program: 32336
Project: 32336
Buggy source:
/** 
 * Looks for an already connected compatible accessory and connect to it.
 */
private void initializeAccessory(){
  if (!mConfig.getQueryUsbAcc()) {
    logI("String_Node_Str");
    return;
  }
  logI("String_Node_Str");
  UsbAccessory acc=mConfig.getUsbAccessory();
  if (acc == null || !isAccessorySupported(acc)) {
    UsbManager usbManager=getUsbManager();
    UsbAccessory[] accessories=usbManager.getAccessoryList();
    if (accessories != null) {
      logD("String_Node_Str" + accessories.length + "String_Node_Str");
      for (      UsbAccessory accessory : accessories) {
        if (isAccessorySupported(accessory)) {
          acc=accessory;
          break;
        }
      }
    }
 else {
      logI("String_Node_Str");
      return;
    }
  }
  connectToAccessory(acc);
}

Fixed version (ground truth):
/** 
 * Looks for an already connected compatible accessory and connect to it.
 */
private void initializeAccessory(){
  UsbAccessory acc=mConfig.getUsbAccessory();
  if (!mConfig.getQueryUsbAcc() && acc == null) {
    logI("String_Node_Str");
    return;
  }
  logI("String_Node_Str");
  if (acc == null || !isAccessorySupported(acc)) {
    UsbManager usbManager=getUsbManager();
    UsbAccessory[] accessories=usbManager.getAccessoryList();
    if (accessories != null) {
      logD("String_Node_Str" + accessories.length + "String_Node_Str");
      for (      UsbAccessory accessory : accessories) {
        if (isAccessorySupported(accessory)) {
          acc=accessory;
          break;
        }
      }
    }
 else {
      logI("String_Node_Str");
      return;
    }
  }
  connectToAccessory(acc);
}
Program: 32337
Project: 32337
Buggy source:
protected void cycleProxy(SdlDisconnectedReason disconnectedReason){
  if (_cycling)   return;
synchronized (CYCLE_LOCK) {
    try {
      _cycling=true;
      cleanProxy(disconnectedReason);
      initializeProxy();
      if (!SdlDisconnectedReason.LEGACY_BLUETOOTH_MODE_ENABLED.equals(disconnectedReason)) {
        notifyProxyClosed("String_Node_Str",new SdlException("String_Node_Str",SdlExceptionCause.SDL_PROXY_CYCLED),disconnectedReason);
      }
    }
 catch (    SdlException e) {
      Intent sendIntent=createBroadcastIntent();
      updateBroadcastIntent(sendIntent,"String_Node_Str","String_Node_Str");
      updateBroadcastIntent(sendIntent,"String_Node_Str","String_Node_Str" + e.getSdlExceptionCause());
      sendBroadcastIntent(sendIntent);
switch (e.getSdlExceptionCause()) {
case BLUETOOTH_DISABLED:
        notifyProxyClosed("String_Node_Str",new SdlException("String_Node_Str",SdlExceptionCause.BLUETOOTH_DISABLED),SdlDisconnectedReason.BLUETOOTH_DISABLED);
      break;
case BLUETOOTH_ADAPTER_NULL:
    notifyProxyClosed("String_Node_Str",new SdlException("String_Node_Str",SdlExceptionCause.BLUETOOTH_ADAPTER_NULL),SdlDisconnectedReason.BLUETOOTH_ADAPTER_ERROR);
  break;
default :
notifyProxyClosed("String_Node_Str",e,SdlDisconnectedReason.GENERIC_ERROR);
break;
}
}
catch (Exception e) {
notifyProxyClosed("String_Node_Str",e,SdlDisconnectedReason.GENERIC_ERROR);
}
_cycling=false;
}
}

Fixed version (ground truth):
protected void cycleProxy(SdlDisconnectedReason disconnectedReason){
  if (_cycling)   return;
synchronized (CYCLE_LOCK) {
    try {
      _cycling=true;
      cleanProxy(disconnectedReason);
      initializeProxy();
      if (!SdlDisconnectedReason.LEGACY_BLUETOOTH_MODE_ENABLED.equals(disconnectedReason) && !_transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) {
        notifyProxyClosed("String_Node_Str",new SdlException("String_Node_Str",SdlExceptionCause.SDL_PROXY_CYCLED),disconnectedReason);
      }
    }
 catch (    SdlException e) {
      Intent sendIntent=createBroadcastIntent();
      updateBroadcastIntent(sendIntent,"String_Node_Str","String_Node_Str");
      updateBroadcastIntent(sendIntent,"String_Node_Str","String_Node_Str" + e.getSdlExceptionCause());
      sendBroadcastIntent(sendIntent);
switch (e.getSdlExceptionCause()) {
case BLUETOOTH_DISABLED:
        notifyProxyClosed("String_Node_Str",new SdlException("String_Node_Str",SdlExceptionCause.BLUETOOTH_DISABLED),SdlDisconnectedReason.BLUETOOTH_DISABLED);
      break;
case BLUETOOTH_ADAPTER_NULL:
    notifyProxyClosed("String_Node_Str",new SdlException("String_Node_Str",SdlExceptionCause.BLUETOOTH_ADAPTER_NULL),SdlDisconnectedReason.BLUETOOTH_ADAPTER_ERROR);
  break;
default :
notifyProxyClosed("String_Node_Str",e,SdlDisconnectedReason.GENERIC_ERROR);
break;
}
}
catch (Exception e) {
notifyProxyClosed("String_Node_Str",e,SdlDisconnectedReason.GENERIC_ERROR);
}
_cycling=false;
}
}
Program: 32338
Project: 32338
Buggy source:
protected void handleFirstDataFrame(SdlPacket packet){
  hasFirstFrame=true;
  totalSize=BitConverter.intFromByteArray(packet.payload,0) - HEADER_SIZE;
  framesRemaining=BitConverter.intFromByteArray(packet.payload,4);
  accumulator=new ByteArrayOutputStream(totalSize);
}

Fixed version (ground truth):
protected void handleFirstDataFrame(SdlPacket packet){
  hasFirstFrame=true;
  totalSize=BitConverter.intFromByteArray(packet.payload,0) - HEADER_SIZE;
  framesRemaining=BitConverter.intFromByteArray(packet.payload,4);
  try {
    accumulator=new ByteArrayOutputStream(totalSize);
  }
 catch (  OutOfMemoryError e) {
    DebugTool.logError("String_Node_Str",e);
    accumulator=null;
  }
}
Program: 32339
Project: 32339
Buggy source:
protected void handleMultiFrameMessageFrame(SdlPacket packet){
  if (packet.getFrameType() == FrameType.First) {
    handleFirstDataFrame(packet);
  }
 else {
    handleRemainingFrame(packet);
  }
}

Fixed version (ground truth):
protected void handleMultiFrameMessageFrame(SdlPacket packet){
  if (packet.getFrameType() == FrameType.First) {
    handleFirstDataFrame(packet);
  }
 else {
    if (accumulator != null)     handleRemainingFrame(packet);
  }
}
Program: 32340
Project: 32340
Buggy source:
public LocalRouterService(Parcel p){
  this.version=p.readInt();
  this.timestamp=p.readLong();
  this.launchIntent=p.readParcelable(Intent.class.getClassLoader());
  this.name=p.readParcelable(ComponentName.class.getClassLoader());
}

Fixed version (ground truth):
public LocalRouterService(Parcel p){
  this.version=p.readInt();
  this.timestamp=p.readLong();
  try {
    this.launchIntent=p.readParcelable(Intent.class.getClassLoader());
    this.name=p.readParcelable(ComponentName.class.getClassLoader());
  }
 catch (  Exception e) {
  }
}
Program: 32342
Project: 32342
Buggy source:
/** 
 * This is a simple class to hold onto a reference of a registered app.
 * @param appId
 * @param messenger
 */
public RegisteredApp(long appId,Messenger messenger){
  this.appId=appId;
  this.messenger=messenger;
  this.sessionIds=new Vector<Long>();
  this.queue=new PacketWriteTaskBlockingQueue();
  queueWaitHandler=new Handler();
  setDeathNote();
}

Fixed version (ground truth):
/** 
 * This is a simple class to hold onto a reference of a registered app.
 * @param appId
 * @param messenger
 */
public RegisteredApp(String appId,Messenger messenger){
  this.appId=appId;
  this.messenger=messenger;
  this.sessionIds=new Vector<Long>();
  this.queue=new PacketWriteTaskBlockingQueue();
  queueWaitHandler=new Handler();
  setDeathNote();
}
Program: 32343
Project: 32343
Buggy source:
public long getAppId(){
  return appId;
}

Fixed version (ground truth):
public String getAppId(){
  return appId;
}
Program: 32344
Project: 32344
Buggy source:
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private boolean removeAllSessionsWithAppId(long appId){
synchronized (SESSION_LOCK) {
    if (sessionMap != null) {
      SparseArray<Long> iter=sessionMap.clone();
      int size=iter.size();
      for (int i=0; i < size; i++) {
        if (((Long)iter.valueAt(i)).compareTo(appId) == 0) {
          sessionHashIdMap.remove(iter.keyAt(i));
          sessionMap.removeAt(i);
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private boolean removeAllSessionsWithAppId(String appId){
synchronized (SESSION_LOCK) {
    if (sessionMap != null) {
      SparseArray<String> iter=sessionMap.clone();
      int size=iter.size();
      for (int i=0; i < size; i++) {
        if (((String)iter.valueAt(i)).compareTo(appId) == 0) {
          sessionHashIdMap.remove(iter.keyAt(i));
          sessionMap.removeAt(i);
        }
      }
    }
  }
  return false;
}
Program: 32345
Project: 32345
Buggy source:
private Long getAppIDForSession(int sessionId,boolean shouldAssertNewSession){
synchronized (SESSION_LOCK) {
    if (sessionMap == null) {
      Log.w(TAG,"String_Node_Str");
      sessionMap=new SparseArray<Long>();
    }
    Long appId=sessionMap.get(sessionId);
    if (appId == null && shouldAssertNewSession) {
      int pos;
synchronized (REGISTERED_APPS_LOCK) {
        for (        RegisteredApp app : registeredApps.values()) {
          pos=app.containsSessionId(-1);
          if (pos != -1) {
            app.setSessionId(pos,sessionId);
            appId=app.getAppId();
            sessionMap.put(sessionId,appId);
            break;
          }
        }
      }
    }
    return appId;
  }
}

Fixed version (ground truth):
private String getAppIDForSession(int sessionId,boolean shouldAssertNewSession){
synchronized (SESSION_LOCK) {
    if (sessionMap == null) {
      Log.w(TAG,"String_Node_Str");
      sessionMap=new SparseArray<String>();
    }
    String appId=sessionMap.get(sessionId);
    if (appId == null && shouldAssertNewSession) {
      int pos;
synchronized (REGISTERED_APPS_LOCK) {
        for (        RegisteredApp app : registeredApps.values()) {
          pos=app.containsSessionId(-1);
          if (pos != -1) {
            app.setSessionId(pos,sessionId);
            appId=app.getAppId();
            sessionMap.put(sessionId,appId);
            break;
          }
        }
      }
    }
    return appId;
  }
}
Program: 32346
Project: 32346
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  if (!initCheck()) {
    stopSelf();
    return;
  }
  initPassed=true;
synchronized (REGISTERED_APPS_LOCK) {
    registeredApps=new HashMap<Long,RegisteredApp>();
  }
  closing=false;
  currentContext=getBaseContext();
  startVersionCheck();
  Log.i(TAG,"String_Node_Str");
synchronized (SESSION_LOCK) {
    this.sessionMap=new SparseArray<Long>();
    this.sessionHashIdMap=new SparseArray<Integer>();
  }
  packetExecuter=Executors.newSingleThreadExecutor();
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  if (!initCheck()) {
    stopSelf();
    return;
  }
  initPassed=true;
synchronized (REGISTERED_APPS_LOCK) {
    registeredApps=new HashMap<String,RegisteredApp>();
  }
  closing=false;
  currentContext=getBaseContext();
  startVersionCheck();
  Log.i(TAG,"String_Node_Str");
synchronized (SESSION_LOCK) {
    this.sessionMap=new SparseArray<String>();
    this.sessionHashIdMap=new SparseArray<Integer>();
  }
  packetExecuter=Executors.newSingleThreadExecutor();
}
Program: 32347
Project: 32347
Buggy source:
@Override public int onStartCommand(Intent intent,int flags,int startId){
  if (!initPassed) {
    return super.onStartCommand(intent,flags,startId);
  }
  if (registeredApps == null) {
synchronized (REGISTERED_APPS_LOCK) {
      registeredApps=new HashMap<Long,RegisteredApp>();
    }
  }
  if (intent != null) {
    if (intent.hasExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA)) {
      if (startSequenceComplete) {
        Log.i(TAG,"String_Node_Str");
        initBluetoothSerialService();
      }
    }
  }
  shouldServiceRemainOpen(intent);
  return super.onStartCommand(intent,flags,startId);
}

Fixed version (ground truth):
@Override public int onStartCommand(Intent intent,int flags,int startId){
  if (!initPassed) {
    return super.onStartCommand(intent,flags,startId);
  }
  if (registeredApps == null) {
synchronized (REGISTERED_APPS_LOCK) {
      registeredApps=new HashMap<String,RegisteredApp>();
    }
  }
  if (intent != null) {
    if (intent.hasExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA)) {
      if (startSequenceComplete) {
        Log.i(TAG,"String_Node_Str");
        initBluetoothSerialService();
      }
    }
  }
  shouldServiceRemainOpen(intent);
  return super.onStartCommand(intent,flags,startId);
}
Program: 32348
Project: 32348
Buggy source:
public boolean sendPacketToRouterService(SdlPacket packet){
  if (routerServiceMessenger == null) {
    Log.d(TAG,whereToReply + "String_Node_Str");
    return false;
  }
  if (packet == null) {
    Log.w(TAG,whereToReply + "String_Node_Str");
    return false;
  }
  byte[] bytes=packet.constructPacket();
  if (bytes.length < ByteArrayMessageSpliter.MAX_BINDER_SIZE) {
    Message message=Message.obtain();
    message.what=TransportConstants.ROUTER_SEND_PACKET;
    Bundle bundle=new Bundle();
    bundle.putLong(TransportConstants.APP_ID_EXTRA,appId);
    bundle.putByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME,bytes);
    bundle.putInt(TransportConstants.BYTES_TO_SEND_EXTRA_OFFSET,0);
    bundle.putInt(TransportConstants.BYTES_TO_SEND_EXTRA_COUNT,bytes.length);
    bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS,TransportConstants.BYTES_TO_SEND_FLAG_NONE);
    bundle.putInt(TransportConstants.PACKET_PRIORITY_COEFFICIENT,packet.getPrioirtyCoefficient());
    message.setData(bundle);
    sendMessageToRouterService(message);
    return true;
  }
 else {
    ByteArrayMessageSpliter splitter=new ByteArrayMessageSpliter(appId,TransportConstants.ROUTER_SEND_PACKET,bytes,packet.getPrioirtyCoefficient());
    while (splitter.isActive()) {
      sendMessageToRouterService(splitter.nextMessage());
    }
    return splitter.close();
  }
}

Fixed version (ground truth):
public boolean sendPacketToRouterService(SdlPacket packet){
  if (routerServiceMessenger == null) {
    Log.d(TAG,whereToReply + "String_Node_Str");
    return false;
  }
  if (packet == null) {
    Log.w(TAG,whereToReply + "String_Node_Str");
    return false;
  }
  byte[] bytes=packet.constructPacket();
  if (bytes.length < ByteArrayMessageSpliter.MAX_BINDER_SIZE) {
    Message message=Message.obtain();
    message.what=TransportConstants.ROUTER_SEND_PACKET;
    Bundle bundle=new Bundle();
    if (routerServiceVersion < TransportConstants.RouterServiceVersions.APPID_STRING) {
      bundle.putLong(TransportConstants.APP_ID_EXTRA,convertAppId(appId));
    }
    bundle.putString(TransportConstants.APP_ID_EXTRA_STRING,appId);
    bundle.putByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME,bytes);
    bundle.putInt(TransportConstants.BYTES_TO_SEND_EXTRA_OFFSET,0);
    bundle.putInt(TransportConstants.BYTES_TO_SEND_EXTRA_COUNT,bytes.length);
    bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS,TransportConstants.BYTES_TO_SEND_FLAG_NONE);
    bundle.putInt(TransportConstants.PACKET_PRIORITY_COEFFICIENT,packet.getPrioirtyCoefficient());
    message.setData(bundle);
    sendMessageToRouterService(message);
    return true;
  }
 else {
    ByteArrayMessageSpliter splitter=new ByteArrayMessageSpliter(appId,TransportConstants.ROUTER_SEND_PACKET,bytes,packet.getPrioirtyCoefficient());
    splitter.setRouterServiceVersion(routerServiceVersion);
    while (splitter.isActive()) {
      sendMessageToRouterService(splitter.nextMessage());
    }
    return splitter.close();
  }
}
Program: 32349
Project: 32349
Buggy source:
private void unregisterWithRouterService(){
  Log.i(TAG,"String_Node_Str");
  if (isBound && routerServiceMessenger != null) {
    Message msg=Message.obtain();
    msg.what=TransportConstants.ROUTER_UNREGISTER_CLIENT;
    msg.replyTo=this.clientMessenger;
    Bundle bundle=new Bundle();
    bundle.putLong(TransportConstants.APP_ID_EXTRA,appId);
    msg.setData(bundle);
    sendMessageToRouterService(msg);
  }
 else {
    Log.w(TAG,"String_Node_Str");
  }
  routerServiceMessenger=null;
}

Fixed version (ground truth):
private void unregisterWithRouterService(){
  Log.i(TAG,"String_Node_Str");
  if (isBound && routerServiceMessenger != null) {
    Message msg=Message.obtain();
    msg.what=TransportConstants.ROUTER_UNREGISTER_CLIENT;
    msg.replyTo=this.clientMessenger;
    Bundle bundle=new Bundle();
    if (routerServiceVersion < TransportConstants.RouterServiceVersions.APPID_STRING) {
      bundle.putLong(TransportConstants.APP_ID_EXTRA,convertAppId(appId));
    }
    bundle.putString(TransportConstants.APP_ID_EXTRA_STRING,appId);
    msg.setData(bundle);
    sendMessageToRouterService(msg);
  }
 else {
    Log.w(TAG,"String_Node_Str");
  }
  routerServiceMessenger=null;
}
Program: 32350
Project: 32350
Buggy source:
/** 
 * Use this method to let the router service know that you are requesting a new session from the head unit. 
 */
public void requestNewSession(){
  Message msg=Message.obtain();
  msg.what=TransportConstants.ROUTER_REQUEST_NEW_SESSION;
  msg.replyTo=this.clientMessenger;
  Bundle bundle=new Bundle();
  bundle.putLong(TransportConstants.APP_ID_EXTRA,appId);
  msg.setData(bundle);
  this.sendMessageToRouterService(msg);
}

Fixed version (ground truth):
/** 
 * Use this method to let the router service know that you are requesting a new session from the head unit. 
 */
public void requestNewSession(){
  Message msg=Message.obtain();
  msg.what=TransportConstants.ROUTER_REQUEST_NEW_SESSION;
  msg.replyTo=this.clientMessenger;
  Bundle bundle=new Bundle();
  if (routerServiceVersion < TransportConstants.RouterServiceVersions.APPID_STRING) {
    bundle.putLong(TransportConstants.APP_ID_EXTRA,convertAppId(appId));
  }
  bundle.putString(TransportConstants.APP_ID_EXTRA_STRING,appId);
  msg.setData(bundle);
  this.sendMessageToRouterService(msg);
}
Program: 32351
Project: 32351
Buggy source:
public void removeSession(long sessionId){
  Message msg=Message.obtain();
  msg.what=TransportConstants.ROUTER_REMOVE_SESSION;
  msg.replyTo=this.clientMessenger;
  Bundle bundle=new Bundle();
  bundle.putLong(TransportConstants.APP_ID_EXTRA,appId);
  bundle.putLong(TransportConstants.SESSION_ID_EXTRA,sessionId);
  msg.setData(bundle);
  this.sendMessageToRouterService(msg);
}

Fixed version (ground truth):
public void removeSession(long sessionId){
  Message msg=Message.obtain();
  msg.what=TransportConstants.ROUTER_REMOVE_SESSION;
  msg.replyTo=this.clientMessenger;
  Bundle bundle=new Bundle();
  if (routerServiceVersion < TransportConstants.RouterServiceVersions.APPID_STRING) {
    bundle.putLong(TransportConstants.APP_ID_EXTRA,convertAppId(appId));
  }
  bundle.putString(TransportConstants.APP_ID_EXTRA_STRING,appId);
  bundle.putLong(TransportConstants.SESSION_ID_EXTRA,sessionId);
  msg.setData(bundle);
  this.sendMessageToRouterService(msg);
}
Program: 32353
Project: 32353
Buggy source:
private void sendRegistrationMessage(){
  Message msg=Message.obtain();
  msg.what=TransportConstants.ROUTER_REGISTER_CLIENT;
  msg.replyTo=this.clientMessenger;
  Bundle bundle=new Bundle();
  bundle.putLong(TransportConstants.APP_ID_EXTRA,appId);
  msg.setData(bundle);
  sendMessageToRouterService(msg);
}

Fixed version (ground truth):
private void sendRegistrationMessage(){
  Message msg=Message.obtain();
  msg.what=TransportConstants.ROUTER_REGISTER_CLIENT;
  msg.replyTo=this.clientMessenger;
  Bundle bundle=new Bundle();
  bundle.putLong(TransportConstants.APP_ID_EXTRA,convertAppId(appId));
  bundle.putString(TransportConstants.APP_ID_EXTRA_STRING,appId);
  msg.setData(bundle);
  sendMessageToRouterService(msg);
}
Program: 32354
Project: 32354
Buggy source:
/** 
 * Life Cycle  
 */
@SuppressLint("String_Node_Str") public TransportBroker(Context context,String appId,ComponentName service){
synchronized (INIT_LOCK) {
    clientMessenger=new Messenger(new ClientHandler(this));
    initRouterConnection();
    SimpleDateFormat s=new SimpleDateFormat("String_Node_Str");
    String timeStamp=s.format(new Date(System.currentTimeMillis()));
    if (whereToReply == null) {
      if (appId == null) {
        whereToReply=WHERE_TO_REPLY_PREFIX + "String_Node_Str" + timeStamp;
      }
 else {
        whereToReply=WHERE_TO_REPLY_PREFIX + appId + "String_Node_Str"+ timeStamp;
      }
    }
    this.appId=Long.valueOf(appId.concat(timeStamp));
    queuedOnTransportConnect=null;
    currentContext=context;
    this.routerService=service;
  }
}

Fixed version (ground truth):
/** 
 * Life Cycle  
 */
@SuppressLint("String_Node_Str") public TransportBroker(Context context,String appId,ComponentName service){
synchronized (INIT_LOCK) {
    clientMessenger=new Messenger(new ClientHandler(this));
    initRouterConnection();
    SimpleDateFormat s=new SimpleDateFormat("String_Node_Str");
    String timeStamp=s.format(new Date(System.currentTimeMillis()));
    if (whereToReply == null) {
      if (appId == null) {
        whereToReply=WHERE_TO_REPLY_PREFIX + "String_Node_Str" + timeStamp;
      }
 else {
        whereToReply=WHERE_TO_REPLY_PREFIX + appId + "String_Node_Str"+ timeStamp;
      }
    }
    this.appId=appId.concat(timeStamp);
    queuedOnTransportConnect=null;
    currentContext=context;
    this.routerService=service;
  }
}
Program: 32355
Project: 32355
Buggy source:
public AbstractPacketizer(IStreamListener streamListener,InputStream is,RPCRequest request,SessionType sType,byte rpcSessionID,byte wiproVersion,SdlSession session) throws IOException {
  this._streamListener=streamListener;
  this.is=is;
  _rpcSessionID=rpcSessionID;
  _serviceType=sType;
  _request=request;
  _wiproVersion=wiproVersion;
  this._session=session;
}

Fixed version (ground truth):
public AbstractPacketizer(IStreamListener streamListener,InputStream is,RPCRequest request,SessionType sType,byte rpcSessionID,byte wiproVersion,SdlSession session) throws IOException {
  this._streamListener=streamListener;
  this.is=is;
  _rpcSessionID=rpcSessionID;
  _serviceType=sType;
  _request=request;
  _wiproVersion=wiproVersion;
  this._session=session;
  bufferSize=this._session.getMtu();
  buffer=new byte[bufferSize];
}
Program: 32356
Project: 32356
Buggy source:
public void run(){
  int length;
  try {
    while (t != null && !t.isInterrupted()) {
synchronized (mPauseLock) {
        while (mPaused) {
          try {
            mPauseLock.wait();
          }
 catch (          InterruptedException e) {
          }
        }
      }
      length=is.read(buffer,0,BUFF_READ_SIZE);
      if (length >= 0) {
        ProtocolMessage pm=new ProtocolMessage();
        pm.setSessionID(_rpcSessionID);
        pm.setSessionType(_serviceType);
        pm.setFunctionID(0);
        pm.setCorrID(0);
        pm.setData(buffer,length);
        pm.setPayloadProtected(isServiceProtected);
        if (t != null && !t.isInterrupted())         _streamListener.sendStreamPacket(pm);
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    if (sdlConnection != null) {
      sdlConnection.endService(_serviceType,_rpcSessionID);
    }
  }
}

Fixed version (ground truth):
public void run(){
  int length;
  try {
    while (t != null && !t.isInterrupted()) {
synchronized (mPauseLock) {
        while (mPaused) {
          try {
            mPauseLock.wait();
          }
 catch (          InterruptedException e) {
          }
        }
      }
      length=is.read(buffer,0,bufferSize);
      if (length >= 0) {
        ProtocolMessage pm=new ProtocolMessage();
        pm.setSessionID(_rpcSessionID);
        pm.setSessionType(_serviceType);
        pm.setFunctionID(0);
        pm.setCorrID(0);
        pm.setData(buffer,length);
        pm.setPayloadProtected(isServiceProtected);
        if (t != null && !t.isInterrupted())         _streamListener.sendStreamPacket(pm);
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    if (sdlConnection != null) {
      sdlConnection.endService(_serviceType,_rpcSessionID);
    }
  }
}
Program: 32357
Project: 32357
Buggy source:
public StreamPacketizer(IStreamListener streamListener,InputStream is,SessionType sType,byte rpcSessionID,SdlSession session) throws IOException {
  super(streamListener,is,sType,rpcSessionID,session);
  mPauseLock=new Object();
  mPaused=false;
  isServiceProtected=_session.isServiceProtected(_serviceType);
}

Fixed version (ground truth):
public StreamPacketizer(IStreamListener streamListener,InputStream is,SessionType sType,byte rpcSessionID,SdlSession session) throws IOException {
  super(streamListener,is,sType,rpcSessionID,session);
  mPauseLock=new Object();
  mPaused=false;
  isServiceProtected=_session.isServiceProtected(_serviceType);
  if (isServiceProtected) {
    bufferSize=BUFF_READ_SIZE;
    buffer=new byte[bufferSize];
  }
}
Program: 32359
Project: 32359
Buggy source:
public static BinaryFrameHeader parseBinaryHeader(byte[] binHeader){
  BinaryFrameHeader msg=new BinaryFrameHeader();
  byte RPC_Type=(byte)(binHeader[0] >>> 4);
  msg.setRPCType(RPC_Type);
  int _functionID=(BitConverter.intFromByteArray(binHeader,0) & 0x0FFFFFFF);
  msg.setFunctionID(_functionID);
  int corrID=BitConverter.intFromByteArray(binHeader,4);
  msg.setCorrID(corrID);
  int _jsonSize=BitConverter.intFromByteArray(binHeader,8);
  msg.setJsonSize(_jsonSize);
  if (_jsonSize > 0) {
    byte[] _jsonData=new byte[_jsonSize];
    System.arraycopy(binHeader,12,_jsonData,0,_jsonSize);
    msg.setJsonData(_jsonData);
  }
  if (binHeader.length - _jsonSize - 12 > 0) {
    byte[] _bulkData=new byte[binHeader.length - _jsonSize - 12];
    System.arraycopy(binHeader,12 + _jsonSize,_bulkData,0,_bulkData.length);
    msg.setBulkData(_bulkData);
  }
  return msg;
}

Fixed version (ground truth):
public static BinaryFrameHeader parseBinaryHeader(byte[] binHeader){
  BinaryFrameHeader msg=new BinaryFrameHeader();
  byte RPC_Type=(byte)(binHeader[0] >>> 4);
  msg.setRPCType(RPC_Type);
  int _functionID=(BitConverter.intFromByteArray(binHeader,0) & 0x0FFFFFFF);
  msg.setFunctionID(_functionID);
  int corrID=BitConverter.intFromByteArray(binHeader,4);
  msg.setCorrID(corrID);
  int _jsonSize=BitConverter.intFromByteArray(binHeader,8);
  msg.setJsonSize(_jsonSize);
  try {
    if (_jsonSize > 0) {
      byte[] _jsonData=new byte[_jsonSize];
      System.arraycopy(binHeader,12,_jsonData,0,_jsonSize);
      msg.setJsonData(_jsonData);
    }
    if (binHeader.length - _jsonSize - 12 > 0) {
      byte[] _bulkData=new byte[binHeader.length - _jsonSize - 12];
      System.arraycopy(binHeader,12 + _jsonSize,_bulkData,0,_bulkData.length);
      msg.setBulkData(_bulkData);
    }
  }
 catch (  OutOfMemoryError e) {
    Log.e(TAG,"String_Node_Str");
    return null;
  }
  return msg;
}
Program: 32360
Project: 32360
Buggy source:
private void handleSingleFrameMessageFrame(SdlPacket packet){
  ProtocolMessage message=new ProtocolMessage();
  message.setPayloadProtected(packet.isEncrypted());
  SessionType serviceType=SessionType.valueOf((byte)packet.getServiceType());
  if (serviceType == SessionType.RPC) {
    message.setMessageType(MessageType.RPC);
  }
 else   if (serviceType == SessionType.BULK_DATA) {
    message.setMessageType(MessageType.BULK);
  }
  message.setSessionType(serviceType);
  message.setSessionID((byte)packet.getSessionId());
  boolean isControlService=message.getSessionType().equals(SessionType.CONTROL);
  if (_version > 1 && !isControlService) {
    BinaryFrameHeader binFrameHeader=BinaryFrameHeader.parseBinaryHeader(packet.payload);
    message.setVersion(_version);
    message.setRPCType(binFrameHeader.getRPCType());
    message.setFunctionID(binFrameHeader.getFunctionID());
    message.setCorrID(binFrameHeader.getCorrID());
    if (binFrameHeader.getJsonSize() > 0) {
      message.setData(binFrameHeader.getJsonData());
    }
    if (binFrameHeader.getBulkData() != null) {
      message.setBulkData(binFrameHeader.getBulkData());
    }
  }
 else {
    message.setData(packet.payload);
  }
  _assemblerForMessageID.remove(packet.getMessageId());
  try {
    handleProtocolMessageReceived(message);
  }
 catch (  Exception ex) {
    DebugTool.logError(FailurePropagating_Msg + "String_Node_Str" + ex.toString(),ex);
    handleProtocolError(FailurePropagating_Msg + "String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private void handleSingleFrameMessageFrame(SdlPacket packet){
  ProtocolMessage message=new ProtocolMessage();
  message.setPayloadProtected(packet.isEncrypted());
  SessionType serviceType=SessionType.valueOf((byte)packet.getServiceType());
  if (serviceType == SessionType.RPC) {
    message.setMessageType(MessageType.RPC);
  }
 else   if (serviceType == SessionType.BULK_DATA) {
    message.setMessageType(MessageType.BULK);
  }
  message.setSessionType(serviceType);
  message.setSessionID((byte)packet.getSessionId());
  boolean isControlService=message.getSessionType().equals(SessionType.CONTROL);
  if (_version > 1 && !isControlService) {
    BinaryFrameHeader binFrameHeader=BinaryFrameHeader.parseBinaryHeader(packet.payload);
    if (binFrameHeader == null) {
      return;
    }
    message.setVersion(_version);
    message.setRPCType(binFrameHeader.getRPCType());
    message.setFunctionID(binFrameHeader.getFunctionID());
    message.setCorrID(binFrameHeader.getCorrID());
    if (binFrameHeader.getJsonSize() > 0) {
      message.setData(binFrameHeader.getJsonData());
    }
    if (binFrameHeader.getBulkData() != null) {
      message.setBulkData(binFrameHeader.getBulkData());
    }
  }
 else {
    message.setData(packet.payload);
  }
  _assemblerForMessageID.remove(packet.getMessageId());
  try {
    handleProtocolMessageReceived(message);
  }
 catch (  Exception ex) {
    DebugTool.logError(FailurePropagating_Msg + "String_Node_Str" + ex.toString(),ex);
    handleProtocolError(FailurePropagating_Msg + "String_Node_Str",ex);
  }
}
Program: 32361
Project: 32361
Buggy source:
protected void notifyIfFinished(SdlPacket packet){
  if (packet.getFrameType() == FrameType.Consecutive && packet.getFrameInfo() == 0x0) {
    ProtocolMessage message=new ProtocolMessage();
    message.setPayloadProtected(packet.isEncrypted());
    message.setSessionType(SessionType.valueOf((byte)packet.getServiceType()));
    message.setSessionID((byte)packet.getSessionId());
    if (_version > 1) {
      BinaryFrameHeader binFrameHeader=BinaryFrameHeader.parseBinaryHeader(accumulator.toByteArray());
      message.setVersion(_version);
      message.setRPCType(binFrameHeader.getRPCType());
      message.setFunctionID(binFrameHeader.getFunctionID());
      message.setCorrID(binFrameHeader.getCorrID());
      if (binFrameHeader.getJsonSize() > 0)       message.setData(binFrameHeader.getJsonData());
      if (binFrameHeader.getBulkData() != null)       message.setBulkData(binFrameHeader.getBulkData());
    }
 else {
      message.setData(accumulator.toByteArray());
    }
    _assemblerForMessageID.remove(packet.getMessageId());
    try {
      handleProtocolMessageReceived(message);
    }
 catch (    Exception excp) {
      DebugTool.logError(FailurePropagating_Msg + "String_Node_Str" + excp.toString(),excp);
    }
    hasFirstFrame=false;
    accumulator=null;
  }
}

Fixed version (ground truth):
protected void notifyIfFinished(SdlPacket packet){
  if (packet.getFrameType() == FrameType.Consecutive && packet.getFrameInfo() == 0x0) {
    ProtocolMessage message=new ProtocolMessage();
    message.setPayloadProtected(packet.isEncrypted());
    message.setSessionType(SessionType.valueOf((byte)packet.getServiceType()));
    message.setSessionID((byte)packet.getSessionId());
    if (_version > 1) {
      BinaryFrameHeader binFrameHeader=BinaryFrameHeader.parseBinaryHeader(accumulator.toByteArray());
      if (binFrameHeader == null) {
        return;
      }
      message.setVersion(_version);
      message.setRPCType(binFrameHeader.getRPCType());
      message.setFunctionID(binFrameHeader.getFunctionID());
      message.setCorrID(binFrameHeader.getCorrID());
      if (binFrameHeader.getJsonSize() > 0)       message.setData(binFrameHeader.getJsonData());
      if (binFrameHeader.getBulkData() != null)       message.setBulkData(binFrameHeader.getBulkData());
    }
 else {
      message.setData(accumulator.toByteArray());
    }
    _assemblerForMessageID.remove(packet.getMessageId());
    try {
      handleProtocolMessageReceived(message);
    }
 catch (    Exception excp) {
      DebugTool.logError(FailurePropagating_Msg + "String_Node_Str" + excp.toString(),excp);
    }
    hasFirstFrame=false;
    accumulator=null;
  }
}
Program: 32364
Project: 32364
Buggy source:
@SuppressLint("String_Node_Str") public void cancel(){
  if (broker != null) {
    broker.stop();
    broker=null;
  }
  connected=false;
  if (threadLooper != null) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      threadLooper.quitSafely();
    }
 else {
      threadLooper.quit();
    }
    threadLooper=null;
  }
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") public synchronized void cancel(){
  if (broker != null) {
    broker.stop();
    broker=null;
  }
  connected=false;
  if (threadLooper != null) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      threadLooper.quitSafely();
    }
 else {
      threadLooper.quit();
    }
    threadLooper=null;
  }
}
Program: 32365
Project: 32365
Buggy source:
/** 
 * Checks to make sure bluetooth adapter is available and on
 * @return
 */
private boolean bluetoothAvailable(){
  boolean retVal=(!(BluetoothAdapter.getDefaultAdapter() == null) && BluetoothAdapter.getDefaultAdapter().isEnabled());
  return retVal;
}

Fixed version (ground truth):
/** 
 * Checks to make sure bluetooth adapter is available and on
 * @return
 */
private boolean bluetoothAvailable(){
  try {
    boolean retVal=(!(BluetoothAdapter.getDefaultAdapter() == null) && BluetoothAdapter.getDefaultAdapter().isEnabled());
    return retVal;
  }
 catch (  NullPointerException e) {
    return false;
  }
}
Program: 32366
Project: 32366
Buggy source:
/** 
 * Determines if an instance of the Router Service is currently running on the device. 
 * @param context A context to access Android system services through.
 * @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
 * @return True if a SDL Router Service is currently running, false otherwise.
 */
private static boolean isRouterServiceRunning(Context context,boolean pingService){
  if (context == null) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  ActivityManager manager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  if (runningBluetoothServicePackage == null) {
    runningBluetoothServicePackage=new Vector<ComponentName>();
  }
 else {
    runningBluetoothServicePackage.clear();
  }
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME) && AndroidTools.isServiceExported(context,service.service)) {
      runningBluetoothServicePackage.add(service.service);
      if (pingService) {
        pingRouterService(context,service.service.getPackageName(),service.service.getClassName());
      }
    }
  }
  return runningBluetoothServicePackage.size() > 0;
}

Fixed version (ground truth):
/** 
 * Determines if an instance of the Router Service is currently running on the device. 
 * @param context A context to access Android system services through.
 * @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
 * @return True if a SDL Router Service is currently running, false otherwise.
 */
private static boolean isRouterServiceRunning(Context context,boolean pingService){
  if (context == null) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  ActivityManager manager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  if (runningBluetoothServicePackage == null) {
    runningBluetoothServicePackage=new Vector<ComponentName>();
  }
 else {
    runningBluetoothServicePackage.clear();
  }
  List<RunningServiceInfo> runningServices=null;
  try {
    runningServices=manager.getRunningServices(Integer.MAX_VALUE);
  }
 catch (  NullPointerException e) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  for (  RunningServiceInfo service : runningServices) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME) && AndroidTools.isServiceExported(context,service.service)) {
      runningBluetoothServicePackage.add(service.service);
      if (pingService) {
        pingRouterService(context,service.service.getPackageName(),service.service.getClassName());
      }
    }
  }
  return runningBluetoothServicePackage.size() > 0;
}
Program: 32367
Project: 32367
Buggy source:
private void cleanProxy(SdlDisconnectedReason disconnectedReason) throws SdlException {
  try {
    if (_advancedLifecycleManagementEnabled) {
      _sdlConnectionState=SdlConnectionState.SDL_DISCONNECTED;
      firstTimeFull=true;
      Boolean waitForInterfaceUnregistered=false;
synchronized (CONNECTION_REFERENCE_LOCK) {
        if (sdlSession != null && sdlSession.getIsConnected() && getAppInterfaceRegistered()) {
          waitForInterfaceUnregistered=true;
          unregisterAppInterfacePrivate(UNREGISTER_APP_INTERFACE_CORRELATION_ID);
        }
      }
      if (waitForInterfaceUnregistered) {
synchronized (APP_INTERFACE_REGISTERED_LOCK) {
          try {
            APP_INTERFACE_REGISTERED_LOCK.wait(3000);
          }
 catch (          InterruptedException e) {
          }
        }
      }
    }
    rpcResponseListeners.clear();
    rpcNotificationListeners.clear();
synchronized (CONNECTION_REFERENCE_LOCK) {
      if (sdlSession != null)       sdlSession.close();
    }
  }
 catch (  SdlException e) {
    throw e;
  }
 finally {
    SdlTrace.logProxyEvent("String_Node_Str",SDL_LIB_TRACE_KEY);
  }
}

Fixed version (ground truth):
private void cleanProxy(SdlDisconnectedReason disconnectedReason) throws SdlException {
  try {
    if (_advancedLifecycleManagementEnabled) {
      _sdlConnectionState=SdlConnectionState.SDL_DISCONNECTED;
      firstTimeFull=true;
      Boolean waitForInterfaceUnregistered=false;
synchronized (CONNECTION_REFERENCE_LOCK) {
        if (sdlSession != null && sdlSession.getIsConnected() && getAppInterfaceRegistered()) {
          waitForInterfaceUnregistered=true;
          unregisterAppInterfacePrivate(UNREGISTER_APP_INTERFACE_CORRELATION_ID);
        }
      }
      if (waitForInterfaceUnregistered) {
synchronized (APP_INTERFACE_REGISTERED_LOCK) {
          try {
            APP_INTERFACE_REGISTERED_LOCK.wait(3000);
          }
 catch (          InterruptedException e) {
          }
        }
      }
    }
    if (rpcResponseListeners != null) {
      rpcResponseListeners.clear();
    }
    if (rpcNotificationListeners != null) {
      rpcNotificationListeners.clear();
    }
synchronized (CONNECTION_REFERENCE_LOCK) {
      if (sdlSession != null)       sdlSession.close();
    }
  }
 catch (  SdlException e) {
    throw e;
  }
 finally {
    SdlTrace.logProxyEvent("String_Node_Str",SDL_LIB_TRACE_KEY);
  }
}
Program: 32368
Project: 32368
Buggy source:
/** 
 * Determines if an instance of the Router Service is currently running on the device. 
 * @param context A context to access Android system services through.
 * @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
 * @return True if a SDL Router Service is currently running, false otherwise.
 */
private static boolean isRouterServiceRunning(Context context,boolean pingService){
  if (context == null) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  ActivityManager manager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  if (runningBluetoothServicePackage == null) {
    runningBluetoothServicePackage=new Vector<ComponentName>();
  }
 else {
    runningBluetoothServicePackage.clear();
  }
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME) && AndroidTools.isServiceExported(context,service.service)) {
      runningBluetoothServicePackage.add(service.service);
      if (pingService) {
        Intent intent=new Intent();
        intent.setClassName(service.service.getPackageName(),service.service.getClassName());
        intent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,pingService);
        context.startService(intent);
      }
    }
  }
  return runningBluetoothServicePackage.size() > 0;
}

Fixed version (ground truth):
/** 
 * Determines if an instance of the Router Service is currently running on the device. 
 * @param context A context to access Android system services through.
 * @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
 * @return True if a SDL Router Service is currently running, false otherwise.
 */
private static boolean isRouterServiceRunning(Context context,boolean pingService){
  if (context == null) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  ActivityManager manager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  if (runningBluetoothServicePackage == null) {
    runningBluetoothServicePackage=new Vector<ComponentName>();
  }
 else {
    runningBluetoothServicePackage.clear();
  }
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME) && AndroidTools.isServiceExported(context,service.service)) {
      runningBluetoothServicePackage.add(service.service);
      if (pingService) {
        pingRouterService(context,service.service.getPackageName(),service.service.getClassName());
      }
    }
  }
  return runningBluetoothServicePackage.size() > 0;
}
Program: 32369
Project: 32369
Buggy source:
private boolean wakeUpRouterService(Context context,boolean ping,boolean altTransportWake){
  if (!isRouterServiceRunning(context,ping)) {
    Intent serviceIntent=new Intent(context,localRouterClass);
    if (altTransportWake) {
      serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
    }
    context.startService(serviceIntent);
    return true;
  }
 else {
    if (altTransportWake && runningBluetoothServicePackage != null && runningBluetoothServicePackage.size() > 0) {
      Intent serviceIntent=new Intent();
      serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
      for (      ComponentName compName : runningBluetoothServicePackage) {
        serviceIntent.setComponent(compName);
        context.startService(serviceIntent);
      }
      return true;
    }
    return false;
  }
}

Fixed version (ground truth):
private boolean wakeUpRouterService(Context context,boolean ping,boolean altTransportWake){
  if (!isRouterServiceRunning(context,ping)) {
    Intent serviceIntent=new Intent(context,localRouterClass);
    if (altTransportWake) {
      serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
    }
    try {
      context.startService(serviceIntent);
    }
 catch (    SecurityException e) {
      Log.e(TAG,"String_Node_Str");
      return false;
    }
    return true;
  }
 else {
    if (altTransportWake && runningBluetoothServicePackage != null && runningBluetoothServicePackage.size() > 0) {
      Intent serviceIntent=new Intent();
      serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
      for (      ComponentName compName : runningBluetoothServicePackage) {
        serviceIntent.setComponent(compName);
        context.startService(serviceIntent);
      }
      return true;
    }
    return false;
  }
}
Program: 32370
Project: 32370
Buggy source:
/** 
 * Write to the connected OutStream.
 * @param buffer  The bytes to write
 */
public void write(byte[] buffer,int offset,int count){
  try {
    if (buffer == null) {
      Log.w(TAG,"String_Node_Str");
      return;
    }
    mmOutStream.write(buffer,offset,count);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str");
    getBluetoothSerialServerInstance().connectionLost();
  }
}

Fixed version (ground truth):
/** 
 * Write to the connected OutStream.
 * @param buffer  The bytes to write
 */
public void write(byte[] buffer,int offset,int count){
  try {
    if (buffer == null) {
      Log.w(TAG,"String_Node_Str");
      return;
    }
    mmOutStream.write(buffer,offset,count);
  }
 catch (  IOException|NullPointerException e) {
    Log.e(TAG,"String_Node_Str");
    getBluetoothSerialServerInstance().connectionLost();
  }
}
Program: 32372
Project: 32372
Buggy source:
public void testForceConnectEvent(){
  SdlConnection.enableLegacyMode(false,null);
  assertNull(SdlConnectionTestClass.cachedMultiConfig);
  RouterServiceValidator rsvp=new RouterServiceValidator(this.mContext);
  rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_PERFORM_ALL_CHECKS);
  MultiplexTransportConfig config=new MultiplexTransportConfig(this.mContext,SdlUnitTestContants.TEST_APP_ID);
  SdlConnectionTestClass connection=new SdlConnectionTestClass(config,rsvp);
  assertNotNull(SdlConnectionTestClass.cachedMultiConfig);
  assertTrue(SdlConnectionTestClass.isLegacyModeEnabled());
  assertEquals(TransportType.BLUETOOTH,connection.getCurrentTransportType());
  assertNotNull(SdlConnectionTestClass.cachedMultiConfig);
  connection.forceHardwareConnectEvent(TransportType.MULTIPLEX);
  assertFalse(connection.connected);
  assertNotNull(SdlConnectionTestClass.cachedMultiConfig.getService());
  assertEquals(TransportType.MULTIPLEX,connection.getCurrentTransportType());
}

Fixed version (ground truth):
public void testForceConnectEvent(){
  SdlConnection.enableLegacyMode(false,null);
  assertNull(SdlConnectionTestClass.cachedMultiConfig);
  RouterServiceValidator rsvp=new RouterServiceValidator(this.mContext);
  rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_PERFORM_ALL_CHECKS);
  MultiplexTransportConfig config=new MultiplexTransportConfig(this.mContext,SdlUnitTestContants.TEST_APP_ID);
  SdlConnectionTestClass connection=new SdlConnectionTestClass(config,rsvp);
  assertNotNull(SdlConnectionTestClass.cachedMultiConfig);
  assertTrue(SdlConnectionTestClass.isLegacyModeEnabled());
  assertEquals(TransportType.BLUETOOTH,connection.getCurrentTransportType());
  assertNotNull(SdlConnectionTestClass.cachedMultiConfig);
  connection.forceHardwareConnectEvent(TransportType.MULTIPLEX);
  assertFalse(connection.connected);
  assertNotNull(SdlConnectionTestClass.cachedMultiConfig.getService());
  assertEquals(TransportType.MULTIPLEX,connection.getCurrentTransportType());
  MultiplexTransportConfig null_service_config=new MultiplexTransportConfig(this.mContext,SdlUnitTestContants.TEST_APP_ID);
  null_service_config.setService(null);
  SdlConnectionTestClass null_service_connection=new SdlConnectionTestClass(null_service_config,null);
  Exception exception=null;
  try {
    null_service_connection.forceHardwareConnectEvent(TransportType.MULTIPLEX);
  }
 catch (  NullPointerException e) {
    exception=e;
  }
  assertNull(exception);
}