nus-yam/ex-repair huggingface dataset:
Program: 32199
Project: 32199
Buggy source:
@Override public void onSubmit(String text){
  MXSession session=Matrix.getInstance(getApplicationContext()).getDefaultSession();
  session.joinRoom(text,new ApiCallback<String>(){
    @Override public void onSuccess(    String roomId){
      if (null != roomId) {
        CommonActivityUtils.goToRoomPage(roomId,HomeActivity.this,null);
      }
    }
    @Override public void onNetworkError(    Exception e){
      Toast.makeText(HomeActivity.this,getString(R.string.network_error),Toast.LENGTH_LONG).show();
    }
    @Override public void onMatrixError(    MatrixError e){
      Toast.makeText(HomeActivity.this,e.error,Toast.LENGTH_LONG).show();
    }
    @Override public void onUnexpectedError(    Exception e){
      Toast.makeText(HomeActivity.this,e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
    }
  }
);
}

Fixed version (ground truth):
@Override public void onSubmit(String text){
  MXSession session=Matrix.getInstance(getApplicationContext()).getDefaultSession();
  session.joinRoom(text,new ApiCallback<String>(){
    @Override public void onSuccess(    String roomId){
      if (null != roomId) {
        CommonActivityUtils.goToRoomPage(null,roomId,HomeActivity.this,null);
      }
    }
    @Override public void onNetworkError(    Exception e){
      Toast.makeText(HomeActivity.this,getString(R.string.network_error),Toast.LENGTH_LONG).show();
    }
    @Override public void onMatrixError(    MatrixError e){
      Toast.makeText(HomeActivity.this,e.error,Toast.LENGTH_LONG).show();
    }
    @Override public void onUnexpectedError(    Exception e){
      Toast.makeText(HomeActivity.this,e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
    }
  }
);
}
Program: 32200
Project: 32200
Buggy source:
private void joinRoomByName(){
  AlertDialog alert=CommonActivityUtils.createEditTextAlert(this,getString(R.string.join_room_title),getString(R.string.join_room_hint),null,new CommonActivityUtils.OnSubmitListener(){
    @Override public void onSubmit(    String text){
      MXSession session=Matrix.getInstance(getApplicationContext()).getDefaultSession();
      session.joinRoom(text,new ApiCallback<String>(){
        @Override public void onSuccess(        String roomId){
          if (null != roomId) {
            CommonActivityUtils.goToRoomPage(roomId,HomeActivity.this,null);
          }
        }
        @Override public void onNetworkError(        Exception e){
          Toast.makeText(HomeActivity.this,getString(R.string.network_error),Toast.LENGTH_LONG).show();
        }
        @Override public void onMatrixError(        MatrixError e){
          Toast.makeText(HomeActivity.this,e.error,Toast.LENGTH_LONG).show();
        }
        @Override public void onUnexpectedError(        Exception e){
          Toast.makeText(HomeActivity.this,e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
        }
      }
);
    }
    @Override public void onCancelled(){
    }
  }
);
  alert.show();
}

Fixed version (ground truth):
private void joinRoomByName(){
  AlertDialog alert=CommonActivityUtils.createEditTextAlert(this,getString(R.string.join_room_title),getString(R.string.join_room_hint),null,new CommonActivityUtils.OnSubmitListener(){
    @Override public void onSubmit(    String text){
      MXSession session=Matrix.getInstance(getApplicationContext()).getDefaultSession();
      session.joinRoom(text,new ApiCallback<String>(){
        @Override public void onSuccess(        String roomId){
          if (null != roomId) {
            CommonActivityUtils.goToRoomPage(null,roomId,HomeActivity.this,null);
          }
        }
        @Override public void onNetworkError(        Exception e){
          Toast.makeText(HomeActivity.this,getString(R.string.network_error),Toast.LENGTH_LONG).show();
        }
        @Override public void onMatrixError(        MatrixError e){
          Toast.makeText(HomeActivity.this,e.error,Toast.LENGTH_LONG).show();
        }
        @Override public void onUnexpectedError(        Exception e){
          Toast.makeText(HomeActivity.this,e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
        }
      }
);
    }
    @Override public void onCancelled(){
    }
  }
);
  alert.show();
}
Program: 32201
Project: 32201
Buggy source:
@Override public boolean onChildClick(ExpandableListView parent,View v,int groupPosition,int childPosition,long id){
  String roomId=null;
  if (mAdapter.isRecentsGroupIndex(groupPosition)) {
    roomId=mAdapter.getRoomSummaryAt(childPosition).getRoomId();
    Room room=mSession.getDataHandler().getRoom(roomId);
    if ((null == room) || room.isLeaving()) {
      roomId=null;
    }
    mAdapter.resetUnreadCount(roomId);
  }
 else   if (mAdapter.isPublicsGroupIndex(groupPosition)) {
    roomId=mAdapter.getPublicRoomAt(childPosition).roomId;
  }
  if (null != roomId) {
    CommonActivityUtils.goToRoomPage(roomId,HomeActivity.this,null);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onChildClick(ExpandableListView parent,View v,int groupPosition,int childPosition,long id){
  String roomId=null;
  if (mAdapter.isRecentsGroupIndex(groupPosition)) {
    roomId=mAdapter.getRoomSummaryAt(childPosition).getRoomId();
    Room room=mSession.getDataHandler().getRoom(roomId);
    if ((null == room) || room.isLeaving()) {
      roomId=null;
    }
    mAdapter.resetUnreadCount(roomId);
  }
 else   if (mAdapter.isPublicsGroupIndex(groupPosition)) {
    roomId=mAdapter.getPublicRoomAt(childPosition).roomId;
  }
  if (null != roomId) {
    CommonActivityUtils.goToRoomPage(null,roomId,HomeActivity.this,null);
  }
  return true;
}
Program: 32203
Project: 32203
Buggy source:
@Override protected void onResume(){
  super.onResume();
  MyPresenceManager.getInstance(this).advertiseOnline();
  mIsPaused=false;
  mAdapter.sortSummaries();
  collapseAllGroups();
  mAdapter.setDisplayAllGroups(mSearchRoomEditText.getVisibility() == View.VISIBLE);
  expandAllGroups();
  mAdapter.notifyDataSetChanged();
  if (null != mAutomaticallyOpenedRoomId) {
    runOnUiThread(new Runnable(){
      @Override public void run(){
        CommonActivityUtils.goToRoomPage(HomeActivity.this.mAutomaticallyOpenedRoomId,HomeActivity.this,mOpenedRoomIntent);
        HomeActivity.this.mAutomaticallyOpenedRoomId=null;
        HomeActivity.this.mOpenedRoomIntent=null;
      }
    }
);
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  MyPresenceManager.getInstance(this).advertiseOnline();
  mIsPaused=false;
  mAdapter.sortSummaries();
  collapseAllGroups();
  mAdapter.setDisplayAllGroups(mSearchRoomEditText.getVisibility() == View.VISIBLE);
  expandAllGroups();
  mAdapter.notifyDataSetChanged();
  if (null != mAutomaticallyOpenedRoomId) {
    runOnUiThread(new Runnable(){
      @Override public void run(){
        CommonActivityUtils.goToRoomPage(null,HomeActivity.this.mAutomaticallyOpenedRoomId,HomeActivity.this,mOpenedRoomIntent);
        HomeActivity.this.mAutomaticallyOpenedRoomId=null;
        HomeActivity.this.mOpenedRoomIntent=null;
      }
    }
);
  }
}
Program: 32204
Project: 32204
Buggy source:
@Override public void onSuccess(String roomId){
  if (null != roomId) {
    CommonActivityUtils.goToRoomPage(roomId,HomeActivity.this,null);
  }
}

Fixed version (ground truth):
@Override public void onSuccess(String roomId){
  if (null != roomId) {
    CommonActivityUtils.goToRoomPage(null,roomId,HomeActivity.this,null);
  }
}
Program: 32205
Project: 32205
Buggy source:
/** 
 * Return the used MXSession from an intent.
 * @param intent
 * @return the MXsession if it exists.
 */
protected MXSession getSession(Intent intent){
  MXSession session=null;
  if (intent.hasExtra(EXTRA_FROM_MX_USER_ID)) {
    session=Matrix.getInstance(getApplicationContext()).getSession(intent.getStringExtra(EXTRA_FROM_MX_USER_ID));
  }
  if (null == session) {
    session=Matrix.getInstance(getApplicationContext()).getDefaultSession();
  }
  return session;
}

Fixed version (ground truth):
/** 
 * Return the used MXSession from an intent.
 * @param intent
 * @return the MXsession if it exists.
 */
protected MXSession getSession(Intent intent){
  MXSession session=null;
  if (intent.hasExtra(EXTRA_ACCOUNT_ID)) {
    session=Matrix.getInstance(getApplicationContext()).getSession(intent.getStringExtra(EXTRA_ACCOUNT_ID));
  }
  if (null == session) {
    session=Matrix.getInstance(getApplicationContext()).getDefaultSession();
  }
  return session;
}
Program: 32210
Project: 32210
Buggy source:
@Override public void onAvatarClick(String roomId,String userId){
  Intent startRoomInfoIntent=new Intent(mContext,MemberDetailsActivity.class);
  startRoomInfoIntent.putExtra(MemberDetailsActivity.EXTRA_ROOM_ID,roomId);
  startRoomInfoIntent.putExtra(MemberDetailsActivity.EXTRA_MEMBER_ID,userId);
  startRoomInfoIntent.putExtra(MemberDetailsActivity.EXTRA_FROM_MX_USER_ID,mSession.getCredentials().userId);
  mContext.startActivity(startRoomInfoIntent);
}

Fixed version (ground truth):
@Override public void onAvatarClick(String roomId,String userId){
  Intent startRoomInfoIntent=new Intent(mContext,MemberDetailsActivity.class);
  startRoomInfoIntent.putExtra(MemberDetailsActivity.EXTRA_ROOM_ID,roomId);
  startRoomInfoIntent.putExtra(MemberDetailsActivity.EXTRA_MEMBER_ID,userId);
  startRoomInfoIntent.putExtra(MemberDetailsActivity.EXTRA_ACCOUNT_ID,mSession.getCredentials().userId);
  mContext.startActivity(startRoomInfoIntent);
}
Program: 32213
Project: 32213
Buggy source:
private void setTopic(String topic){
  this.getActionBar().setSubtitle(topic);
}

Fixed version (ground truth):
private void setTopic(String topic){
  if (null != this.getActionBar()) {
    this.getActionBar().setSubtitle(topic);
  }
}
Program: 32214
Project: 32214
Buggy source:
@Override public void onNetworkError(Exception e){
  Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
  Log.i(LOG_TAG,"String_Node_Str");
  try {
    Thread.sleep(RETRY_WAIT_TIME_MS);
  }
 catch (  InterruptedException e1) {
    Log.e(LOG_TAG,"String_Node_Str" + e1.getMessage());
  }
}

Fixed version (ground truth):
@Override public void onNetworkError(Exception e){
  super.onNetworkError(e);
  latch.countDown();
}
Program: 32215
Project: 32215
Buggy source:
@Override public void run(){
  Log.d(LOG_TAG,"String_Node_Str");
  mPaused=false;
  while (!mInitialSyncDone) {
    final CountDownLatch latch=new CountDownLatch(1);
    mApiClient.initialSync(new DefaultApiCallback<InitialSyncResponse>(){
      @Override public void onSuccess(      InitialSyncResponse initialSync){
        Log.i(LOG_TAG,"String_Node_Str");
        mListener.onInitialSyncComplete(initialSync);
        mCurrentToken=initialSync.end;
        mInitialSyncDone=true;
        latch.countDown();
      }
    }
);
    try {
      latch.await();
    }
 catch (    InterruptedException e) {
      Log.e(LOG_TAG,"String_Node_Str");
    }
  }
  Log.d(LOG_TAG,"String_Node_Str" + mCurrentToken);
  while (!mKilling) {
    if (mPaused) {
      Log.i(LOG_TAG,"String_Node_Str");
      try {
synchronized (this) {
          wait();
        }
        Log.i(LOG_TAG,"String_Node_Str");
      }
 catch (      InterruptedException e) {
        Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
      }
    }
    try {
      TokensChunkResponse<Event> eventsResponse=mApiClient.events(mCurrentToken);
      mListener.onEventsReceived(eventsResponse.chunk);
      mCurrentToken=eventsResponse.end;
    }
 catch (    RetrofitError error) {
      eventsFailureCallback.failure(error);
    }
  }
  Log.d(LOG_TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void run(){
  Log.d(LOG_TAG,"String_Node_Str");
  mPaused=false;
  while (!mInitialSyncDone) {
    final CountDownLatch latch=new CountDownLatch(1);
    mApiClient.initialSync(new DefaultApiCallback<InitialSyncResponse>(){
      @Override public void onSuccess(      InitialSyncResponse initialSync){
        Log.i(LOG_TAG,"String_Node_Str");
        mListener.onInitialSyncComplete(initialSync);
        mCurrentToken=initialSync.end;
        mInitialSyncDone=true;
        latch.countDown();
      }
      @Override public void onNetworkError(      Exception e){
        super.onNetworkError(e);
        latch.countDown();
      }
    }
);
    try {
      latch.await();
    }
 catch (    InterruptedException e) {
      Log.e(LOG_TAG,"String_Node_Str");
    }
  }
  Log.d(LOG_TAG,"String_Node_Str" + mCurrentToken);
  while (!mKilling) {
    if (mPaused) {
      Log.i(LOG_TAG,"String_Node_Str");
      try {
synchronized (this) {
          wait();
        }
        Log.i(LOG_TAG,"String_Node_Str");
      }
 catch (      InterruptedException e) {
        Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
      }
    }
    try {
      TokensChunkResponse<Event> eventsResponse=mApiClient.events(mCurrentToken);
      mListener.onEventsReceived(eventsResponse.chunk);
      mCurrentToken=eventsResponse.end;
    }
 catch (    RetrofitError error) {
      eventsFailureCallback.failure(error);
    }
  }
  Log.d(LOG_TAG,"String_Node_Str");
}
Program: 32216
Project: 32216
Buggy source:
private void stop(){
  Log.d(LOG_TAG,"String_Node_Str");
  stopForeground(true);
  if (mSession != null) {
    mSession.stopEventStream();
  }
  mSession=null;
}

Fixed version (ground truth):
private void stop(){
  Log.d(LOG_TAG,"String_Node_Str");
  stopForeground(true);
  if (mSession != null) {
    mSession.stopEventStream();
  }
  mSession=null;
  mStarted=false;
}
Program: 32218
Project: 32218
Buggy source:
/** 
 * Constructs a new AddSubMenu object
 * @param menuID an integer object representing a Menu ID <p><b>Notes:</b> Min Value: 0; Max Value: 2000000000</p>
 * @param menuName String which will be displayed representing this submenu item
 */
public AddSubMenu(@NonNull Integer menuID,@NonNull String menuName){
  this();
}

Fixed version (ground truth):
/** 
 * Constructs a new AddSubMenu object
 * @param menuID an integer object representing a Menu ID <p><b>Notes:</b> Min Value: 0; Max Value: 2000000000</p>
 * @param menuName String which will be displayed representing this submenu item
 */
public AddSubMenu(@NonNull Integer menuID,@NonNull String menuName){
  this();
  setMenuID(menuID);
  setMenuName(menuName);
}
Program: 32222
Project: 32222
Buggy source:
@Override public void onResponse(int correlationId,RPCResponse response){
  if (response.getSuccess()) {
    listener.onUpdate(rpcs.size());
    try {
      sendSequentialRequests(rpcs,listener);
    }
 catch (    SdlException e) {
      e.printStackTrace();
      listener.onError(correlationId,Result.GENERIC_ERROR,e.toString());
    }
  }
}

Fixed version (ground truth):
@Override public void onResponse(int correlationId,RPCResponse response){
  if (response.getSuccess()) {
    if (listener != null) {
      listener.onUpdate(rpcs.size());
    }
    try {
      sendSequentialRequests(rpcs,listener);
    }
 catch (    SdlException e) {
      e.printStackTrace();
      if (listener != null) {
        listener.onError(correlationId,Result.GENERIC_ERROR,e.toString());
      }
    }
  }
}
Program: 32226
Project: 32226
Buggy source:
/** 
 * Performs actual work of sending array of bytes over the transport
 * @param msgBytes Bytes to send
 * @param offset Offset in the bytes array to send data from
 * @param length Number of bytes to send
 * @return True if data was sent successfully, False otherwise
 */
@Override protected boolean sendBytesOverTransport(SdlPacket packet){
  TCPTransportState currentState=getCurrentState();
  byte[] msgBytes=packet.constructPacket();
  logInfo(String.format("String_Node_Str",msgBytes.length,0,msgBytes.length,currentState.name()));
  boolean bResult=false;
  if (currentState == TCPTransportState.CONNECTED) {
    if (mOutputStream != null) {
      logInfo("String_Node_Str");
      try {
        mOutputStream.write(msgBytes,0,msgBytes.length);
        bResult=true;
        logInfo("String_Node_Str");
      }
 catch (      IOException e) {
        logError("String_Node_Str" + e.getMessage());
        bResult=false;
      }
    }
 else {
      logError("String_Node_Str");
    }
  }
 else {
    logInfo("String_Node_Str");
    bResult=false;
  }
  return bResult;
}

Fixed version (ground truth):
/** 
 * Performs actual work of sending array of bytes over the transport
 * @param msgBytes Bytes to send
 * @param offset Offset in the bytes array to send data from
 * @param length Number of bytes to send
 * @return True if data was sent successfully, False otherwise
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected boolean sendBytesOverTransport(SdlPacket packet){
  TCPTransportState currentState=getCurrentState();
  byte[] msgBytes=packet.constructPacket();
  logInfo(String.format("String_Node_Str",msgBytes.length,0,msgBytes.length,currentState.name()));
  boolean bResult=false;
  if (currentState == TCPTransportState.CONNECTED) {
    if (mOutputStream != null) {
      logInfo("String_Node_Str");
      try {
        mOutputStream.write(msgBytes,0,msgBytes.length);
        bResult=true;
        logInfo("String_Node_Str");
      }
 catch (      IOException|NetworkOnMainThreadException e) {
        logError("String_Node_Str" + e.getMessage());
        bResult=false;
      }
    }
 else {
      logError("String_Node_Str");
    }
  }
 else {
    logInfo("String_Node_Str");
    bResult=false;
  }
  return bResult;
}
Program: 32227
Project: 32227
Buggy source:
/** 
 * Gets speechCapabilities set when application interface is registered.
 * @return SpeechCapabilities
 */
@SuppressWarnings("String_Node_Str") public List<SpeechCapabilities> getSpeechCapabilities(){
  return (List<SpeechCapabilities>)getObject(SpeechCapabilities.class,KEY_SPEECH_CAPABILITIES);
}

Fixed version (ground truth):
/** 
 * Gets speechCapabilities set when application interface is registered.
 * @return SpeechCapabilities
 */
@SuppressWarnings("String_Node_Str") public List<SpeechCapabilities> getSpeechCapabilities(){
  Object speechCapabilities=getObject(SpeechCapabilities.class,KEY_SPEECH_CAPABILITIES);
  if (speechCapabilities instanceof List<?>) {
    return (List<SpeechCapabilities>)speechCapabilities;
  }
 else   if (speechCapabilities instanceof SpeechCapabilities) {
    List<SpeechCapabilities> newSpeechCapList=new ArrayList<>();
    newSpeechCapList.add((SpeechCapabilities)speechCapabilities);
    return newSpeechCapList;
  }
  return null;
}
Program: 32228
Project: 32228
Buggy source:
public ServiceFinder(Context context,String packageName,final ServiceFinderCallback callback){
  this.receiverLocation=packageName + "String_Node_Str";
  this.context=context.getApplicationContext();
  this.callback=callback;
  this.services=new Vector<>();
  this.sdlMultiMap=AndroidTools.getSdlEnabledApps(context,packageName);
  this.context.registerReceiver(mainServiceReceiver,new IntentFilter(this.receiverLocation));
  timeoutRunnable=new Runnable(){
    @Override public void run(){
      onFinished();
    }
  }
;
  timeoutHandler=new Handler();
  timeoutHandler.postDelayed(timeoutRunnable,TIMEOUT + (50 * packageName.length()));
  context.sendBroadcast(createQueryIntent(this.receiverLocation));
}

Fixed version (ground truth):
public ServiceFinder(Context context,String packageName,final ServiceFinderCallback callback){
  this.receiverLocation=packageName + "String_Node_Str";
  this.context=context.getApplicationContext();
  this.callback=callback;
  this.services=new Vector<>();
  this.sdlMultiMap=AndroidTools.getSdlEnabledApps(context,packageName);
  this.context.registerReceiver(mainServiceReceiver,new IntentFilter(this.receiverLocation));
  timeoutRunnable=new Runnable(){
    @Override public void run(){
      onFinished();
    }
  }
;
  timeoutHandler=new Handler(Looper.getMainLooper());
  timeoutHandler.postDelayed(timeoutRunnable,TIMEOUT + (50 * packageName.length()));
  context.sendBroadcast(createQueryIntent(this.receiverLocation));
}
Program: 32230
Project: 32230
Buggy source:
public void onTransportDisconnected(TransportType type){
  if (altTransportService != null) {
    return;
  }
  Log.e(TAG,"String_Node_Str");
  connectedTransportType=null;
  isTransportConnected=false;
  stopClientPings();
  exitForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  cachedModuleVersion=-1;
  if (registeredApps == null || registeredApps.isEmpty()) {
    Intent unregisterIntent=new Intent();
    unregisterIntent.putExtra(HARDWARE_DISCONNECTED,type.name());
    unregisterIntent.putExtra(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    unregisterIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
    sendBroadcast(unregisterIntent);
  }
 else {
    Message message=Message.obtain();
    message.what=TransportConstants.HARDWARE_CONNECTION_EVENT;
    Bundle bundle=new Bundle();
    bundle.putString(HARDWARE_DISCONNECTED,type.name());
    bundle.putBoolean(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    message.setData(bundle);
    notifyClients(message);
  }
synchronized (SESSION_LOCK) {
    this.sessionMap.clear();
    this.sessionHashIdMap.clear();
  }
synchronized (REGISTERED_APPS_LOCK) {
    if (registeredApps == null) {
      return;
    }
    registeredApps.clear();
  }
}

Fixed version (ground truth):
public void onTransportDisconnected(TransportType type){
  if (altTransportService != null) {
    return;
  }
  Log.e(TAG,"String_Node_Str");
  connectedTransportType=null;
  isTransportConnected=false;
  stopClientPings();
  exitForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  cachedModuleVersion=-1;
  if (registeredApps != null && !registeredApps.isEmpty()) {
    Message message=Message.obtain();
    message.what=TransportConstants.HARDWARE_CONNECTION_EVENT;
    Bundle bundle=new Bundle();
    bundle.putString(HARDWARE_DISCONNECTED,type.name());
    bundle.putBoolean(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    message.setData(bundle);
    notifyClients(message);
  }
synchronized (SESSION_LOCK) {
    this.sessionMap.clear();
    this.sessionHashIdMap.clear();
  }
synchronized (REGISTERED_APPS_LOCK) {
    if (registeredApps == null) {
      return;
    }
    registeredApps.clear();
  }
}
Program: 32231
Project: 32231
Buggy source:
public void onTransportConnected(final TransportType type){
  isTransportConnected=true;
  cancelForegroundTimeOut();
  enterForeground("String_Node_Str" + this.getConnectedDeviceName(),0);
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  packetWriteTaskMaster=new PacketWriteTaskMaster();
  packetWriteTaskMaster.start();
  connectedTransportType=type;
  Intent startService=new Intent();
  startService.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
  List<ResolveInfo> sdlApps=getPackageManager().queryBroadcastReceivers(startService,0);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
  startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED,true);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(this,this.getClass()));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
  }
  if (sdlApps != null && sdlApps.size() > 0) {
    for (    ResolveInfo app : sdlApps) {
      startService.setClassName(app.activityInfo.applicationInfo.packageName,app.activityInfo.name);
      sendBroadcast(startService);
    }
  }
  if (!(registeredApps == null || registeredApps.isEmpty())) {
    notifyClients(createHardwareConnectedMessage(type));
  }
}

Fixed version (ground truth):
public void onTransportConnected(final TransportType type){
  isTransportConnected=true;
  cancelForegroundTimeOut();
  enterForeground("String_Node_Str" + this.getConnectedDeviceName(),0);
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  packetWriteTaskMaster=new PacketWriteTaskMaster();
  packetWriteTaskMaster.start();
  connectedTransportType=type;
  Intent startService=new Intent();
  startService.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
  startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED,true);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(this,this.getClass()));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
  }
  sendExplicitBroadcast(startService,null);
  if (!(registeredApps == null || registeredApps.isEmpty())) {
    notifyClients(createHardwareConnectedMessage(type));
  }
}
Program: 32232
Project: 32232
Buggy source:
private void startClientPings(){
synchronized (this) {
    if (!isTransportConnected) {
      return;
    }
    if (isPingingClients) {
      Log.w(TAG,"String_Node_Str");
synchronized (PING_COUNT_LOCK) {
        pingCount=0;
      }
      return;
    }
    if (clientPingExecutor == null) {
      clientPingExecutor=Executors.newSingleThreadScheduledExecutor();
    }
    isPingingClients=true;
synchronized (PING_COUNT_LOCK) {
      pingCount=0;
    }
    clientPingExecutor.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        if (getPingCount() >= 10) {
          Log.d(TAG,"String_Node_Str");
          stopClientPings();
          return;
        }
        if (pingIntent == null) {
          initPingIntent();
        }
        getBaseContext().sendBroadcast(pingIntent);
synchronized (PING_COUNT_LOCK) {
          pingCount++;
        }
      }
    }
,CLIENT_PING_DELAY,CLIENT_PING_DELAY,TimeUnit.MILLISECONDS);
  }
}

Fixed version (ground truth):
private void startClientPings(){
synchronized (this) {
    if (!isTransportConnected) {
      return;
    }
    if (isPingingClients) {
      Log.w(TAG,"String_Node_Str");
synchronized (PING_COUNT_LOCK) {
        pingCount=0;
      }
      return;
    }
    if (clientPingExecutor == null) {
      clientPingExecutor=Executors.newSingleThreadScheduledExecutor();
    }
    isPingingClients=true;
synchronized (PING_COUNT_LOCK) {
      pingCount=0;
    }
    clientPingExecutor.scheduleAtFixedRate(new Runnable(){
      List<ResolveInfo> sdlApps;
      @Override public void run(){
        if (getPingCount() >= 10) {
          Log.d(TAG,"String_Node_Str");
          stopClientPings();
          return;
        }
        if (pingIntent == null) {
          initPingIntent();
        }
        if (sdlApps == null) {
          sdlApps=getPackageManager().queryBroadcastReceivers(pingIntent,0);
        }
        sendExplicitBroadcast(pingIntent,sdlApps);
synchronized (PING_COUNT_LOCK) {
          pingCount++;
        }
      }
    }
,CLIENT_PING_DELAY,CLIENT_PING_DELAY,TimeUnit.MILLISECONDS);
  }
}
Program: 32234
Project: 32234
Buggy source:
/** 
 * This method is an all else fails situation. If the head unit is out of sync with the apps on the phone this method will clear out an unwanted or out of date session.
 * @param session the session id that is to be cleaned up
 * @param version the last known version that this session was operating with
 */
private void attemptToCleanUpModule(int session,int version){
  Log.i(TAG,"String_Node_Str" + session);
  byte[] uai=createForceUnregisterApp((byte)session,(byte)version);
  manuallyWriteBytes(uai,0,uai.length);
  int hashId=0;
synchronized (this.SESSION_LOCK) {
    if (this.sessionHashIdMap.indexOfKey(session) >= 0) {
      hashId=this.sessionHashIdMap.get(session);
      this.sessionHashIdMap.delete(session);
    }
  }
  byte[] stopService=(SdlPacketFactory.createEndSession(SessionType.RPC,(byte)session,0,(byte)version,BitConverter.intToByteArray(hashId))).constructPacket();
  manuallyWriteBytes(stopService,0,stopService.length);
}

Fixed version (ground truth):
/** 
 * This method is an all else fails situation. If the head unit is out of sync with the apps on the phone this method will clear out an unwanted or out of date session.
 * @param session the session id that is to be cleaned up
 * @param version the last known version that this session was operating with
 */
private void attemptToCleanUpModule(int session,int version){
  Log.i(TAG,"String_Node_Str" + session);
  byte[] uai=createForceUnregisterApp((byte)session,(byte)version);
  manuallyWriteBytes(uai,0,uai.length);
  int hashId=0;
synchronized (this.SESSION_LOCK) {
    if (this.sessionHashIdMap.indexOfKey(session) >= 0) {
      hashId=this.sessionHashIdMap.get(session);
      this.sessionHashIdMap.delete(session);
      this.cleanedSessionMap.put(session,hashId);
    }
  }
  byte[] stopService=(SdlPacketFactory.createEndSession(SessionType.RPC,(byte)session,0,(byte)version,BitConverter.intToByteArray(hashId))).constructPacket();
  manuallyWriteBytes(stopService,0,stopService.length);
}
Program: 32235
Project: 32235
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  if (!initCheck()) {
    deployNextRouterService();
    stopSelf();
    return;
  }
  initPassed=true;
synchronized (REGISTERED_APPS_LOCK) {
    registeredApps=new HashMap<String,RegisteredApp>();
  }
  closing=false;
  Log.i(TAG,"String_Node_Str");
synchronized (SESSION_LOCK) {
    this.sessionMap=new SparseArray<String>();
    this.sessionHashIdMap=new SparseIntArray();
  }
  packetExecutor=Executors.newSingleThreadExecutor();
  startUpSequence();
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  if (!initCheck()) {
    deployNextRouterService();
    stopSelf();
    return;
  }
  initPassed=true;
synchronized (REGISTERED_APPS_LOCK) {
    registeredApps=new HashMap<String,RegisteredApp>();
  }
  closing=false;
  Log.i(TAG,"String_Node_Str");
synchronized (SESSION_LOCK) {
    this.sessionMap=new SparseArray<String>();
    this.sessionHashIdMap=new SparseIntArray();
    this.cleanedSessionMap=new SparseIntArray();
  }
  packetExecutor=Executors.newSingleThreadExecutor();
  startUpSequence();
}
Program: 32236
Project: 32236
Buggy source:
public ClientHandler(SdlRouterStatusProvider provider){
  this.provider=new WeakReference<SdlRouterStatusProvider>(provider);
}

Fixed version (ground truth):
public ClientHandler(SdlRouterStatusProvider provider){
  super(Looper.getMainLooper());
  this.provider=new WeakReference<SdlRouterStatusProvider>(provider);
}
Program: 32237
Project: 32237
Buggy source:
private void exitForeground(){
  if (isForeground) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      NotificationManager notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
      if (notificationManager != null) {
        notificationManager.deleteNotificationChannel(TransportConstants.SDL_NOTIFICATION_CHANNEL_ID);
      }
    }
    this.stopForeground(true);
  }
}

Fixed version (ground truth):
private void exitForeground(){
  if (isForeground) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      NotificationManager notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
      if (notificationManager != null) {
        notificationManager.deleteNotificationChannel(TransportConstants.SDL_NOTIFICATION_CHANNEL_ID);
      }
    }
    this.stopForeground(true);
    isForeground=false;
  }
}
Program: 32238
Project: 32238
Buggy source:
public void onTransportConnected(final TransportType type){
  isTransportConnected=true;
  enterForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  packetWriteTaskMaster=new PacketWriteTaskMaster();
  packetWriteTaskMaster.start();
  connectedTransportType=type;
  Intent startService=new Intent();
  startService.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
  List<ResolveInfo> sdlApps=getPackageManager().queryBroadcastReceivers(startService,0);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
  startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED,true);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(this,this.getClass()));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
  }
  if (sdlApps != null && sdlApps.size() > 0) {
    for (    ResolveInfo app : sdlApps) {
      startService.setClassName(app.activityInfo.applicationInfo.packageName,app.activityInfo.name);
      sendBroadcast(startService);
    }
  }
  if (!(registeredApps == null || registeredApps.isEmpty())) {
    notifyClients(createHardwareConnectedMessage(type));
  }
}

Fixed version (ground truth):
public void onTransportConnected(final TransportType type){
  isTransportConnected=true;
  cancelForegroundTimeOut();
  enterForeground("String_Node_Str" + this.getConnectedDeviceName(),0);
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  packetWriteTaskMaster=new PacketWriteTaskMaster();
  packetWriteTaskMaster.start();
  connectedTransportType=type;
  Intent startService=new Intent();
  startService.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
  List<ResolveInfo> sdlApps=getPackageManager().queryBroadcastReceivers(startService,0);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
  startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED,true);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(this,this.getClass()));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
  }
  if (sdlApps != null && sdlApps.size() > 0) {
    for (    ResolveInfo app : sdlApps) {
      startService.setClassName(app.activityInfo.applicationInfo.packageName,app.activityInfo.name);
      sendBroadcast(startService);
    }
  }
  if (!(registeredApps == null || registeredApps.isEmpty())) {
    notifyClients(createHardwareConnectedMessage(type));
  }
}
Program: 32239
Project: 32239
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<String,RegisteredApp>();
    }
  }
  if (intent != null) {
    if (intent.getBooleanExtra(FOREGROUND_EXTRA,false)) {
      enterForeground();
    }
    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):
@SuppressLint({"String_Node_Str","String_Node_Str"}) @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.getBooleanExtra(FOREGROUND_EXTRA,false)) {
      BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();
      int timeout=FOREGROUND_TIMEOUT;
      int state=adapter.getProfileConnectionState(BluetoothProfile.A2DP);
      if (state == BluetoothAdapter.STATE_CONNECTED) {
        timeout*=2;
      }
      enterForeground("String_Node_Str",timeout);
      resetForegroundTimeOut(timeout);
    }
    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: 32242
Project: 32242
Buggy source:
/** 
 * The method will attempt to start up the next router service in line based on the sorting criteria of best router service.
 */
protected void deployNextRouterService(){
  List<SdlAppInfo> sdlAppInfoList=AndroidTools.querySdlAppInfo(getApplicationContext(),new SdlAppInfo.BestRouterComparator());
  if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty()) {
    ComponentName name=new ComponentName(this,this.getClass());
    SdlAppInfo info;
    int listSize=sdlAppInfoList.size();
    for (int i=0; i < listSize; i++) {
      info=sdlAppInfoList.get(i);
      if (info.getRouterServiceComponentName().equals(name) && listSize > i) {
        SdlAppInfo nextUp=sdlAppInfoList.get(i + 1);
        Intent serviceIntent=new Intent();
        serviceIntent.setComponent(nextUp.getRouterServiceComponentName());
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
          startService(serviceIntent);
        }
 else {
          try {
            startForegroundService(serviceIntent);
          }
 catch (          Exception e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
          }
        }
        break;
      }
    }
  }
 else {
    Log.d(TAG,"String_Node_Str");
    return;
  }
  closing=true;
  closeBluetoothSerialServer();
  notifyAltTransportOfClose(TransportConstants.ROUTER_SHUTTING_DOWN_REASON_NEWER_SERVICE);
}

Fixed version (ground truth):
/** 
 * The method will attempt to start up the next router service in line based on the sorting criteria of best router service.
 */
protected void deployNextRouterService(){
  List<SdlAppInfo> sdlAppInfoList=AndroidTools.querySdlAppInfo(getApplicationContext(),new SdlAppInfo.BestRouterComparator());
  if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty()) {
    ComponentName name=new ComponentName(this,this.getClass());
    SdlAppInfo info;
    int listSize=sdlAppInfoList.size();
    for (int i=0; i < listSize - 1; i++) {
      info=sdlAppInfoList.get(i);
      if (info.getRouterServiceComponentName().equals(name) && listSize > i) {
        SdlAppInfo nextUp=sdlAppInfoList.get(i + 1);
        Intent serviceIntent=new Intent();
        serviceIntent.setComponent(nextUp.getRouterServiceComponentName());
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
          startService(serviceIntent);
        }
 else {
          try {
            startForegroundService(serviceIntent);
          }
 catch (          Exception e) {
            Log.e(TAG,"String_Node_Str" + e.getMessage());
          }
        }
        break;
      }
    }
  }
 else {
    Log.d(TAG,"String_Node_Str");
    return;
  }
  closing=true;
  closeBluetoothSerialServer();
  notifyAltTransportOfClose(TransportConstants.ROUTER_SHUTTING_DOWN_REASON_NEWER_SERVICE);
}
Program: 32244
Project: 32244
Buggy source:
/** 
 * Finds all SDL apps via their SdlRouterService manifest entry. It will return the metadata associated with that router service.
 * @param context a context instance to obtain the package manager
 * @param comparator the Comparator to sort the resulting list. If null is supplied, they will be returned as they are from the system
 * @return the sorted list of SdlAppInfo objects that represent SDL apps
 */
public static List<SdlAppInfo> querySdlAppInfo(Context context,Comparator<SdlAppInfo> comparator){
  List<SdlAppInfo> sdlAppInfoList=new ArrayList<>();
  Intent intent=new Intent(TransportConstants.ROUTER_SERVICE_ACTION);
  List<ResolveInfo> resolveInfoList=context.getPackageManager().queryIntentServices(intent,PackageManager.GET_META_DATA);
  if (resolveInfoList != null && resolveInfoList.size() > 0) {
    PackageManager packageManager=context.getPackageManager();
    if (packageManager != null) {
      for (      ResolveInfo info : resolveInfoList) {
        PackageInfo packageInfo=null;
        try {
          packageInfo=packageManager.getPackageInfo(info.serviceInfo.packageName,0);
        }
 catch (        NameNotFoundException e) {
        }
 finally {
          sdlAppInfoList.add(new SdlAppInfo(info,packageInfo));
        }
      }
    }
    if (comparator != null) {
      Collections.sort(sdlAppInfoList,comparator);
    }
  }
  return sdlAppInfoList;
}

Fixed version (ground truth):
/** 
 * Finds all SDL apps via their SdlRouterService manifest entry. It will return the metadata associated with that router service.
 * @param context a context instance to obtain the package manager
 * @param comparator the Comparator to sort the resulting list. If null is supplied, they will be returned as they are from the system
 * @return the sorted list of SdlAppInfo objects that represent SDL apps
 */
public static List<SdlAppInfo> querySdlAppInfo(Context context,Comparator<SdlAppInfo> comparator){
  List<SdlAppInfo> sdlAppInfoList=new ArrayList<>();
  Intent intent=new Intent(TransportConstants.ROUTER_SERVICE_ACTION);
  List<ResolveInfo> resolveInfoList=context.getPackageManager().queryIntentServices(intent,PackageManager.GET_META_DATA);
  if (resolveInfoList != null && resolveInfoList.size() > 0) {
    PackageManager packageManager=context.getPackageManager();
    if (packageManager != null) {
      for (      ResolveInfo info : resolveInfoList) {
        PackageInfo packageInfo=null;
        try {
          packageInfo=packageManager.getPackageInfo(info.serviceInfo.packageName,0);
          sdlAppInfoList.add(new SdlAppInfo(info,packageInfo));
        }
 catch (        NameNotFoundException e) {
        }
      }
    }
    if (comparator != null) {
      Collections.sort(sdlAppInfoList,comparator);
    }
  }
  return sdlAppInfoList;
}
Program: 32245
Project: 32245
Buggy source:
@Override public int compare(SdlAppInfo one,SdlAppInfo two){
  if (one != null) {
    if (two != null) {
      if (one.isCustomRouterService) {
        if (two.isCustomRouterService) {
          return 0;
        }
 else {
          return -1;
        }
      }
 else       if (two.isCustomRouterService) {
        return -1;
      }
      int versionCompare=two.routerServiceVersion - one.routerServiceVersion;
      if (versionCompare == 0) {
        int updateTime=(int)(two.lastUpdateTime - one.lastUpdateTime);
        if (updateTime == 0) {
          return one.routerServiceComponentName.getPackageName().compareTo(two.routerServiceComponentName.getPackageName());
        }
 else {
          return updateTime;
        }
      }
 else {
        return versionCompare;
      }
    }
 else {
      return -1;
    }
  }
 else {
    if (two != null) {
      return 1;
    }
  }
  return 0;
}

Fixed version (ground truth):
@Override public int compare(SdlAppInfo one,SdlAppInfo two){
  if (one != null) {
    if (two != null) {
      if (one.isCustomRouterService) {
        if (two.isCustomRouterService) {
          return 0;
        }
 else {
          return 1;
        }
      }
 else       if (two.isCustomRouterService) {
        return -1;
      }
      int versionCompare=two.routerServiceVersion - one.routerServiceVersion;
      if (versionCompare == 0) {
        int updateTime=(int)(two.lastUpdateTime - one.lastUpdateTime);
        if (updateTime == 0) {
          return one.routerServiceComponentName.getPackageName().compareTo(two.routerServiceComponentName.getPackageName());
        }
 else {
          return updateTime;
        }
      }
 else {
        return versionCompare;
      }
    }
 else {
      return -1;
    }
  }
 else {
    if (two != null) {
      return 1;
    }
  }
  return 0;
}
Program: 32247
Project: 32247
Buggy source:
/** 
 * Opens a video service (service type 11) and subsequently provides an IVideoStreamListener to the app to send video data. The supplied VideoStreamingParameters will be set as desired paramaters that will be used to negotiate
 * @param isEncrypted Specify true if packets on this service have to be encrypted
 * @param parameters  Video streaming parameters including: codec which will be used for streaming (currently, onlyVideoStreamingCodec.H264 is accepted), height and width of the video in pixels.
 * @return IVideoStreamListener interface if service is opened successfully and streaming isstarted, null otherwise
 */
@SuppressWarnings("String_Node_Str") public IVideoStreamListener startVideoStream(boolean isEncrypted,VideoStreamingParameters parameters){
  if (sdlSession == null) {
    DebugTool.logWarning("String_Node_Str");
    return null;
  }
  if (sdlSession.getSdlConnection() == null) {
    DebugTool.logWarning("String_Node_Str");
    return null;
  }
  sdlSession.setDesiredVideoParams(parameters);
  VideoStreamingParameters acceptedParams=tryStartVideoStream(isEncrypted,parameters);
  if (acceptedParams != null) {
    return sdlSession.startVideoStream();
  }
 else   if (getWiProVersion() < 5) {
    sdlSession.setAcceptedVideoParams(new VideoStreamingParameters());
    return sdlSession.startVideoStream();
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Opens a video service (service type 11) and subsequently provides an IVideoStreamListener to the app to send video data. The supplied VideoStreamingParameters will be set as desired paramaters that will be used to negotiate
 * @param isEncrypted Specify true if packets on this service have to be encrypted
 * @param parameters  Video streaming parameters including: codec which will be used for streaming (currently, onlyVideoStreamingCodec.H264 is accepted), height and width of the video in pixels.
 * @return IVideoStreamListener interface if service is opened successfully and streaming isstarted, null otherwise
 */
@SuppressWarnings("String_Node_Str") public IVideoStreamListener startVideoStream(boolean isEncrypted,VideoStreamingParameters parameters){
  if (sdlSession == null) {
    DebugTool.logWarning("String_Node_Str");
    return null;
  }
  if (sdlSession.getSdlConnection() == null) {
    DebugTool.logWarning("String_Node_Str");
    return null;
  }
  sdlSession.setDesiredVideoParams(parameters);
  VideoStreamingParameters acceptedParams=tryStartVideoStream(isEncrypted,parameters);
  if (acceptedParams != null) {
    return sdlSession.startVideoStream();
  }
 else {
    return null;
  }
}
Program: 32249
Project: 32249
Buggy source:
public VideoStreamingManager(Context context,ISdl iSdl){
  this.context=context;
  this.internalInterface=iSdl;
  encoder=new VirtualDisplayEncoder();
  internalInterface.addServiceListener(SessionType.NAV,this);
  internalInterface.addOnRPCNotificationListener(FunctionID.ON_TOUCH_EVENT,new OnRPCNotificationListener(){
    @Override public void onNotified(    RPCNotification notification){
      if (notification != null && remoteDisplay != null) {
        MotionEvent event=convertTouchEvent((OnTouchEvent)notification);
        if (event != null) {
          remoteDisplay.handleMotionEvent(event);
        }
      }
    }
  }
);
  hapticManager=new HapticInterfaceManager(iSdl);
}

Fixed version (ground truth):
public VideoStreamingManager(Context context,ISdl iSdl){
  this.context=context;
  this.internalInterface=iSdl;
  encoder=new VirtualDisplayEncoder();
  internalInterface.addServiceListener(SessionType.NAV,this);
  internalInterface.addOnRPCNotificationListener(FunctionID.ON_TOUCH_EVENT,new OnRPCNotificationListener(){
    @Override public void onNotified(    RPCNotification notification){
      if (notification != null && remoteDisplay != null) {
        MotionEvent event=convertTouchEvent((OnTouchEvent)notification);
        if (event != null) {
          remoteDisplay.handleMotionEvent(event);
        }
      }
    }
  }
);
  VideoStreamingCapability capability=(VideoStreamingCapability)_systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING);
  if (capability != null && capability.getIsHapticSpatialDataSupported()) {
    hapticManager=new HapticInterfaceManager(iSdl);
  }
}