nus-yam/ex-repair huggingface dataset:
Program: 104962
Project: 104962
Buggy source:
public Canvas(Context context){
  super(context);
  mContext=context;
  mLayout=new RelativeLayout(context);
  mEnabled=true;
  applyAlpha();
  addView(mLayout,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
  mTargets.add(new BubbleTarget(android.R.drawable.ic_delete,Config.BubbleAction.Destroy,0.5f,0.85f));
  if (Config.mTwitterIcon != null) {
    mTargets.add(new BubbleTarget(Config.mTwitterIcon,Config.BubbleAction.ConsumeRight,0.2f,0.2f));
  }
 else {
    mTargets.add(new BubbleTarget(Config.mBrowserIcon,Config.BubbleAction.ConsumeLeft,0.2f,0.2f));
  }
  mTargets.add(new BubbleTarget(Config.mBrowserIcon,Config.BubbleAction.ConsumeLeft,0.8f,0.2f));
  mWindowManager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  mWindowManagerParams.gravity=Gravity.TOP | Gravity.LEFT;
  mWindowManagerParams.x=0;
  mWindowManagerParams.y=0;
  mWindowManagerParams.height=WindowManager.LayoutParams.MATCH_PARENT;
  mWindowManagerParams.width=WindowManager.LayoutParams.MATCH_PARENT;
  mWindowManagerParams.type=WindowManager.LayoutParams.TYPE_PHONE;
  mWindowManagerParams.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
  mWindowManagerParams.format=PixelFormat.TRANSPARENT;
  mWindowManager.addView(this,mWindowManagerParams);
}

Fixed version (ground truth):
public Canvas(Context context){
  super(context);
  mContext=context;
  mLayout=new RelativeLayout(context);
  mEnabled=true;
  applyAlpha();
  addView(mLayout,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
  mTargets.add(new BubbleTarget(android.R.drawable.ic_delete,Config.BubbleAction.Destroy,0.5f,0.85f));
  if (Config.mTwitterIcon != null) {
    mTargets.add(new BubbleTarget(Config.mTwitterIcon,Config.BubbleAction.ConsumeLeft,0.2f,0.2f));
  }
 else {
    mTargets.add(new BubbleTarget(Config.mBrowserIcon,Config.BubbleAction.ConsumeRight,0.2f,0.2f));
  }
  mTargets.add(new BubbleTarget(Config.mBrowserIcon,Config.BubbleAction.ConsumeRight,0.8f,0.2f));
  mWindowManager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  mWindowManagerParams.gravity=Gravity.TOP | Gravity.LEFT;
  mWindowManagerParams.x=0;
  mWindowManagerParams.y=0;
  mWindowManagerParams.height=WindowManager.LayoutParams.MATCH_PARENT;
  mWindowManagerParams.width=WindowManager.LayoutParams.MATCH_PARENT;
  mWindowManagerParams.type=WindowManager.LayoutParams.TYPE_PHONE;
  mWindowManagerParams.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
  mWindowManagerParams.format=PixelFormat.TRANSPARENT;
  mWindowManager.addView(this,mWindowManagerParams);
}
Program: 104963
Project: 104963
Buggy source:
private void doTargetAction(Config.BubbleAction action,String url){
switch (action) {
case ConsumeLeft:
{
      MainActivity.loadInBrowser(mContext,url,true);
    }
  break;
case ConsumeRight:
{
  Intent intent=new Intent(Intent.ACTION_SEND);
  intent.setType("String_Node_Str");
  intent.setClassName("String_Node_Str","String_Node_Str");
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(Intent.EXTRA_TEXT,url);
  mContext.startActivity(intent);
}
break;
default :
break;
}
}

Fixed version (ground truth):
private void doTargetAction(Config.BubbleAction action,String url){
switch (action) {
case ConsumeRight:
{
      MainActivity.loadInBrowser(mContext,url,true);
    }
  break;
case ConsumeLeft:
{
  Intent intent=new Intent(Intent.ACTION_SEND);
  intent.setType("String_Node_Str");
  intent.setClassName("String_Node_Str","String_Node_Str");
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(Intent.EXTRA_TEXT,url);
  mContext.startActivity(intent);
}
break;
default :
break;
}
}
Program: 104964
Project: 104964
Buggy source:
void setConsumeBubble(Config.BubbleAction bubbleType,String label,String packageName,String activityClassName){
  SharedPreferences.Editor editor=mSharedPreferences.edit();
switch (bubbleType) {
case ConsumeRight:
    editor.putString(PREFERENCE_LEFT_CONSUME_BUBBLE_LABEL,label);
  editor.putString(PREFERENCE_LEFT_CONSUME_BUBBLE_PACKAGE_NAME,packageName);
editor.putString(PREFERENCE_LEFT_CONSUME_BUBBLE_ACTIVITY_CLASS_NAME,activityClassName);
break;
case ConsumeLeft:
editor.putString(PREFERENCE_RIGHT_CONSUME_BUBBLE_LABEL,label);
editor.putString(PREFERENCE_RIGHT_CONSUME_BUBBLE_PACKAGE_NAME,packageName);
editor.putString(PREFERENCE_RIGHT_CONSUME_BUBBLE_ACTIVITY_CLASS_NAME,activityClassName);
break;
}
editor.commit();
}

Fixed version (ground truth):
void setConsumeBubble(Config.BubbleAction bubbleType,String label,String packageName,String activityClassName){
  SharedPreferences.Editor editor=mSharedPreferences.edit();
switch (bubbleType) {
case ConsumeLeft:
    editor.putString(PREFERENCE_LEFT_CONSUME_BUBBLE_LABEL,label);
  editor.putString(PREFERENCE_LEFT_CONSUME_BUBBLE_PACKAGE_NAME,packageName);
editor.putString(PREFERENCE_LEFT_CONSUME_BUBBLE_ACTIVITY_CLASS_NAME,activityClassName);
break;
case ConsumeRight:
editor.putString(PREFERENCE_RIGHT_CONSUME_BUBBLE_LABEL,label);
editor.putString(PREFERENCE_RIGHT_CONSUME_BUBBLE_PACKAGE_NAME,packageName);
editor.putString(PREFERENCE_RIGHT_CONSUME_BUBBLE_ACTIVITY_CLASS_NAME,activityClassName);
break;
}
editor.commit();
}
Program: 104965
Project: 104965
Buggy source:
String getConsumeBubbleLabel(Config.BubbleAction bubbleType){
switch (bubbleType) {
case ConsumeRight:
    return mSharedPreferences.getString(PREFERENCE_LEFT_CONSUME_BUBBLE_LABEL,null);
case ConsumeLeft:
  return mSharedPreferences.getString(PREFERENCE_RIGHT_CONSUME_BUBBLE_LABEL,null);
}
return null;
}

Fixed version (ground truth):
String getConsumeBubbleLabel(Config.BubbleAction bubbleType){
switch (bubbleType) {
case ConsumeLeft:
    return mSharedPreferences.getString(PREFERENCE_LEFT_CONSUME_BUBBLE_LABEL,null);
case ConsumeRight:
  return mSharedPreferences.getString(PREFERENCE_RIGHT_CONSUME_BUBBLE_LABEL,null);
}
return null;
}
Program: 104966
Project: 104966
Buggy source:
@Override public boolean onPreferenceClick(Preference preference){
  AlertDialog alertDialog=getConfigureBubbleAlert(Config.BubbleAction.ConsumeLeft,rightConsumeBubblePreference);
  alertDialog.show();
  return true;
}

Fixed version (ground truth):
@Override public boolean onPreferenceClick(Preference preference){
  AlertDialog alertDialog=getConfigureBubbleAlert(Config.BubbleAction.ConsumeRight,rightConsumeBubblePreference);
  alertDialog.show();
  return true;
}
Program: 104967
Project: 104967
Buggy source:
/** 
 * Creates a new music folder.
 * @param musicFolder The music folder to create.
 */
public void createMusicFolder(MusicFolder musicFolder){
  String sql="String_Node_Str" + INSERT_COLUMNS + "String_Node_Str";
  update(sql,musicFolder.getPath(),musicFolder.getName(),musicFolder.isEnabled(),musicFolder.getChanged());
  Integer id=queryForInt("String_Node_Str",0);
  update("String_Node_Str" + userDao.getUserTable(),id);
  LOG.info("String_Node_Str" + musicFolder.getPath());
}

Fixed version (ground truth):
/** 
 * Creates a new music folder.
 * @param musicFolder The music folder to create.
 */
public void createMusicFolder(MusicFolder musicFolder){
  String sql="String_Node_Str" + INSERT_COLUMNS + "String_Node_Str";
  update(sql,musicFolder.getPath().getPath(),musicFolder.getName(),musicFolder.isEnabled(),musicFolder.getChanged());
  Integer id=queryForInt("String_Node_Str",0);
  update("String_Node_Str" + userDao.getUserTable(),id);
  LOG.info("String_Node_Str" + musicFolder.getPath());
}
Program: 104968
Project: 104968
Buggy source:
/** 
 * Creates a new player.
 * @param player The player to create.
 */
public synchronized void createPlayer(Player player){
  int id=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class) + 1;
  player.setId(String.valueOf(id));
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,player.getId(),player.getName(),player.getType(),player.getUsername(),player.getIpAddress(),player.isAutoControlEnabled(),player.isM3uBomEnabled(),player.getLastSeen(),CoverArtScheme.MEDIUM.name(),player.getTranscodeScheme().name(),player.isDynamicIp(),player.getTechnology().name(),player.getClientId());
  addPlaylist(player);
  LOG.info("String_Node_Str" + id + '.');
}

Fixed version (ground truth):
/** 
 * Creates a new player.
 * @param player The player to create.
 */
public synchronized void createPlayer(Player player){
  Integer existingMax=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class);
  if (existingMax == null) {
    existingMax=0;
  }
  int id=existingMax + 1;
  player.setId(String.valueOf(id));
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,player.getId(),player.getName(),player.getType(),player.getUsername(),player.getIpAddress(),player.isAutoControlEnabled(),player.isM3uBomEnabled(),player.getLastSeen(),CoverArtScheme.MEDIUM.name(),player.getTranscodeScheme().name(),player.isDynamicIp(),player.getTechnology().name(),player.getClientId());
  addPlaylist(player);
  LOG.info("String_Node_Str" + id + '.');
}
Program: 104969
Project: 104969
Buggy source:
/** 
 * Creates a new transcoding.
 * @param transcoding The transcoding to create.
 */
public synchronized void createTranscoding(Transcoding transcoding){
  int id=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class);
  transcoding.setId(id);
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,transcoding.getId(),transcoding.getName(),transcoding.getSourceFormats(),transcoding.getTargetFormat(),transcoding.getStep1(),transcoding.getStep2(),transcoding.getStep3(),transcoding.isDefaultActive());
  LOG.info("String_Node_Str" + transcoding.getName());
}

Fixed version (ground truth):
/** 
 * Creates a new transcoding.
 * @param transcoding The transcoding to create.
 */
public synchronized void createTranscoding(Transcoding transcoding){
  Integer existingMax=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class);
  if (existingMax == null) {
    existingMax=0;
  }
  transcoding.setId(existingMax + 1);
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,transcoding.getId(),transcoding.getName(),transcoding.getSourceFormats(),transcoding.getTargetFormat(),transcoding.getStep1(),transcoding.getStep2(),transcoding.getStep3(),transcoding.isDefaultActive());
  LOG.info("String_Node_Str" + transcoding.getName());
}
Program: 104970
Project: 104970
Buggy source:
/** 
 * Creates a new player.
 * @param player The player to create.
 */
public synchronized void createPlayer(Player player){
  int id=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class) + 1;
  player.setId(String.valueOf(id));
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,player.getId(),player.getName(),player.getType(),player.getUsername(),player.getIpAddress(),player.isAutoControlEnabled(),player.getLastSeen(),CoverArtScheme.MEDIUM.name(),player.getTranscodeScheme().name(),player.isDynamicIp(),player.getTechnology().name(),player.getClientId());
  addPlaylist(player);
  LOG.info("String_Node_Str" + id + '.');
}

Fixed version (ground truth):
/** 
 * Creates a new player.
 * @param player The player to create.
 */
public synchronized void createPlayer(Player player){
  Integer existingMax=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class);
  if (existingMax == null) {
    existingMax=0;
  }
  int id=existingMax + 1;
  player.setId(String.valueOf(id));
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,player.getId(),player.getName(),player.getType(),player.getUsername(),player.getIpAddress(),player.isAutoControlEnabled(),player.getLastSeen(),CoverArtScheme.MEDIUM.name(),player.getTranscodeScheme().name(),player.isDynamicIp(),player.getTechnology().name(),player.getClientId());
  addPlaylist(player);
  LOG.info("String_Node_Str" + id + '.');
}
Program: 104971
Project: 104971
Buggy source:
/** 
 * Creates a new transcoding.
 * @param transcoding The transcoding to create.
 */
public synchronized void createTranscoding(Transcoding transcoding){
  int id=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class);
  transcoding.setId(id);
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,transcoding.getId(),transcoding.getName(),transcoding.getSourceFormats(),transcoding.getTargetFormat(),transcoding.getStep1(),transcoding.getStep2(),transcoding.getStep3(),transcoding.isDefaultActive());
  LOG.info("String_Node_Str" + transcoding.getName());
}

Fixed version (ground truth):
/** 
 * Creates a new transcoding.
 * @param transcoding The transcoding to create.
 */
public synchronized void createTranscoding(Transcoding transcoding){
  Integer existingMax=getJdbcTemplate().queryForObject("String_Node_Str",Integer.class);
  if (existingMax == null) {
    existingMax=0;
  }
  transcoding.setId(existingMax + 1);
  String sql="String_Node_Str" + COLUMNS + "String_Node_Str"+ questionMarks(COLUMNS)+ "String_Node_Str";
  update(sql,transcoding.getId(),transcoding.getName(),transcoding.getSourceFormats(),transcoding.getTargetFormat(),transcoding.getStep1(),transcoding.getStep2(),transcoding.getStep3(),transcoding.isDefaultActive());
  LOG.info("String_Node_Str" + transcoding.getName());
}
Program: 104975
Project: 104975
Buggy source:
/** 
 * Expires the   {@link Channel}s of a specific <tt>Videobridge</tt> if they have been inactive for more than their advertised <tt>expire</tt> number of seconds.
 * @param videobridge the <tt>Videobridge</tt> which is to have its<tt>Channel</tt>s expired if they have been inactive for more than their advertised <tt>expire</tt> number of seconds
 */
private void expire(Videobridge videobridge){
  logger.info("String_Node_Str");
  for (  Conference conference : videobridge.getConferences()) {
    if (conference.shouldExpire()) {
      conference.safeExpire();
    }
 else {
      for (      Content content : conference.getContents()) {
        if (content.shouldExpire()) {
          content.safeExpire();
        }
 else {
          for (          Channel channel : content.getChannels()) {
            if (channel.shouldExpire()) {
              channel.safeExpire();
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Expires the   {@link Channel}s of a specific <tt>Videobridge</tt> if they have been inactive for more than their advertised <tt>expire</tt> number of seconds.
 * @param videobridge the <tt>Videobridge</tt> which is to have its<tt>Channel</tt>s expired if they have been inactive for more than their advertised <tt>expire</tt> number of seconds
 */
private void expire(Videobridge videobridge){
  logger.info("String_Node_Str");
  for (  Conference conference : videobridge.getConferences()) {
    if (conference.shouldExpire()) {
      EXPIRE_EXECUTOR.execute(conference::safeExpire);
    }
 else {
      for (      Content content : conference.getContents()) {
        if (content.shouldExpire()) {
          EXPIRE_EXECUTOR.execute(content::safeExpire);
        }
 else {
          for (          Channel channel : content.getChannels()) {
            if (channel.shouldExpire()) {
              EXPIRE_EXECUTOR.execute(channel::safeExpire);
            }
          }
        }
      }
    }
  }
}
Program: 104979
Project: 104979
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean setRtpEncodingParameters(List<SourcePacketExtension> sources,List<SourceGroupPacketExtension> sourceGroups){
  boolean changed=super.setRtpEncodingParameters(sources,sourceGroups);
  if (changed) {
    Channel[] peerChannels=getContent().getChannels();
    if (!ArrayUtils.isNullOrEmpty(peerChannels)) {
      for (int i=0; i < peerChannels.length; i++) {
        if (peerChannels[i] == this) {
          continue;
        }
        ((VideoChannel)peerChannels[i]).bitrateController.update(null);
      }
    }
  }
  return changed;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean setRtpEncodingParameters(List<SourcePacketExtension> sources,List<SourceGroupPacketExtension> sourceGroups){
  boolean changed=super.setRtpEncodingParameters(sources,sourceGroups);
  if (changed) {
    Channel[] peerChannels=getContent().getChannels();
    if (!ArrayUtils.isNullOrEmpty(peerChannels)) {
      for (      Channel peerChannel : peerChannels) {
        if (peerChannel == this) {
          continue;
        }
        ((VideoChannel)peerChannel).bitrateController.update(null);
      }
    }
  }
  return changed;
}
Program: 104980
Project: 104980
Buggy source:
/** 
 * Sends a message with <tt>colibriClass</tt> <tt>LastNEndpointsChangeEvent</tt> to the <tt>Endpoint</tt> of this <tt>VideoChannel</tt> in order to notify it that the list/set of <tt>lastN</tt> has changed.
 * @param endpointsEnteringLastN the <tt>Endpoint</tt>s which are enteringthe list of <tt>Endpoint</tt>s defined by <tt>lastN</tt>
 */
public void sendLastNEndpointsChangeEventOnDataChannel(List<String> forwardedEndpoints,List<String> endpointsEnteringLastN,List<String> conferenceEndpoints){
  Endpoint thisEndpoint=getEndpoint();
  if (thisEndpoint == null)   return;
  if (endpointsEnteringLastN == null)   endpointsEnteringLastN=forwardedEndpoints;
  StringBuilder msg=new StringBuilder("String_Node_Str");
{
    msg.append("String_Node_Str");
    msg.append(getJsonString(forwardedEndpoints));
    msg.append("String_Node_Str");
    msg.append(getJsonString(endpointsEnteringLastN));
    msg.append("String_Node_Str");
    msg.append(getJsonString(conferenceEndpoints));
  }
  msg.append('}');
  try {
    thisEndpoint.sendMessageOnDataChannel(msg.toString());
  }
 catch (  IOException e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Sends a message with <tt>colibriClass</tt> <tt>LastNEndpointsChangeEvent</tt> to the <tt>Endpoint</tt> of this <tt>VideoChannel</tt> in order to notify it that the list/set of <tt>lastN</tt> has changed.
 * @param endpointsEnteringLastN the <tt>Endpoint</tt>s which are enteringthe list of <tt>Endpoint</tt>s defined by <tt>lastN</tt>
 */
public void sendLastNEndpointsChangeEventOnDataChannel(Collection<String> forwardedEndpoints,Collection<String> endpointsEnteringLastN,Collection<String> conferenceEndpoints){
  Endpoint thisEndpoint=getEndpoint();
  if (thisEndpoint == null)   return;
  if (endpointsEnteringLastN == null)   endpointsEnteringLastN=forwardedEndpoints;
  StringBuilder msg=new StringBuilder("String_Node_Str");
{
    msg.append("String_Node_Str");
    msg.append(getJsonString(forwardedEndpoints));
    msg.append("String_Node_Str");
    msg.append(getJsonString(endpointsEnteringLastN));
    msg.append("String_Node_Str");
    msg.append(getJsonString(conferenceEndpoints));
  }
  msg.append('}');
  try {
    thisEndpoint.sendMessageOnDataChannel(msg.toString());
  }
 catch (  IOException e) {
    logger.error("String_Node_Str",e);
  }
}
Program: 104982
Project: 104982
Buggy source:
private String getJsonString(List<String> strings){
  JSONArray array=new JSONArray();
  if (strings != null && !strings.isEmpty()) {
    for (    String s : strings) {
      array.add(s);
    }
  }
  return array.toString();
}

Fixed version (ground truth):
private String getJsonString(Collection<String> strings){
  JSONArray array=new JSONArray();
  if (strings != null && !strings.isEmpty()) {
    for (    String s : strings) {
      array.add(s);
    }
  }
  return array.toString();
}
Program: 104983
Project: 104983
Buggy source:
/** 
 * {@inheritDoc}</p> Note, that we don't cache any instances that we create here, so this method should be called no more than once!
 */
@Override public StreamConnector getStreamConnector(Channel channel){
  if (!getChannels().contains(channel))   return null;
  MultiplexingDatagramSocket rtpSocket=iceStream.getComponent(Component.RTP).getSocket();
  MultiplexingDatagramSocket rtcpSocket;
  if (numComponents > 1 && !rtcpmux) {
    rtcpSocket=iceStream.getComponent(Component.RTCP).getSocket();
  }
 else {
    rtcpSocket=rtpSocket;
  }
  if (rtpSocket == null || rtcpSocket == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (channel instanceof SctpConnection) {
    try {
      DatagramSocket dtlsSocket=rtpSocket.getSocket(new DTLSDatagramFilter());
      return new DefaultStreamConnector(dtlsSocket,null);
    }
 catch (    SocketException se) {
      logger.warn("String_Node_Str" + se);
    }
  }
  if (!(channel instanceof RtpChannel))   return null;
  RtpChannel rtpChannel=(RtpChannel)channel;
  DatagramSocket channelRtpSocket, channelRtcpSocket;
  try {
    channelRtpSocket=rtpSocket.getSocket(rtpChannel.getDatagramFilter(false));
    channelRtcpSocket=rtcpSocket.getSocket(rtpChannel.getDatagramFilter(false));
  }
 catch (  SocketException se) {
    throw new RuntimeException("String_Node_Str",se);
  }
  return new DefaultStreamConnector(channelRtpSocket,channelRtcpSocket,rtcpmux);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}</p> Note, that we don't cache any instances that we create here, so this method should be called no more than once for each channel!
 */
@Override public StreamConnector getStreamConnector(Channel channel){
  if (!getChannels().contains(channel)) {
    return null;
  }
  MultiplexingDatagramSocket rtpSocket=iceStream.getComponent(Component.RTP).getSocket();
  MultiplexingDatagramSocket rtcpSocket;
  if (numComponents > 1 && !rtcpmux) {
    rtcpSocket=iceStream.getComponent(Component.RTCP).getSocket();
  }
 else {
    rtcpSocket=rtpSocket;
  }
  if (rtpSocket == null || rtcpSocket == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (channel instanceof SctpConnection) {
    try {
      DatagramSocket dtlsSocket=rtpSocket.getSocket(new DTLSDatagramFilter());
      return new DefaultStreamConnector(dtlsSocket,null);
    }
 catch (    SocketException se) {
      logger.warn("String_Node_Str" + se);
    }
  }
  if (!(channel instanceof RtpChannel))   return null;
  RtpChannel rtpChannel=(RtpChannel)channel;
  DatagramSocket channelRtpSocket, channelRtcpSocket;
  try {
    channelRtpSocket=rtpSocket.getSocket(rtpChannel.getDatagramFilter(false));
    channelRtcpSocket=rtcpSocket.getSocket(rtpChannel.getDatagramFilter(true));
  }
 catch (  SocketException se) {
    throw new RuntimeException("String_Node_Str",se);
  }
  return new DefaultStreamConnector(channelRtpSocket,channelRtcpSocket,rtcpmux);
}
Program: 104986
Project: 104986
Buggy source:
private org.jivesoftware.smack.packet.IQ handleIQRequest(org.jivesoftware.smack.packet.IQ request) throws Exception {
  if (request instanceof org.jivesoftware.smackx.packet.Version) {
    return handleVersionIQ((org.jivesoftware.smackx.packet.Version)request);
  }
  Videobridge videobridge=getVideobridge();
  if (videobridge == null) {
    return null;
  }
  org.jivesoftware.smack.packet.IQ response;
  if (request instanceof ColibriConferenceIQ) {
    response=videobridge.handleColibriConferenceIQ((ColibriConferenceIQ)request);
  }
 else   if (request instanceof HealthCheckIQ) {
    response=videobridge.handleHealthCheckIQ((HealthCheckIQ)request);
  }
 else   if (request instanceof ShutdownIQ) {
    response=videobridge.handleShutdownIQ((ShutdownIQ)request);
  }
 else {
    response=null;
  }
  return response;
}

Fixed version (ground truth):
private org.jivesoftware.smack.packet.IQ handleIQRequest(org.jivesoftware.smack.packet.IQ request) throws Exception {
  if (request instanceof org.jivesoftware.smackx.packet.Version) {
    return handleVersionIQ((org.jivesoftware.smackx.packet.Version)request);
  }
  Videobridge videobridge=getVideobridge();
  if (videobridge == null) {
    return IQUtils.createError(request,XMPPError.Condition.interna_server_error,"String_Node_Str");
  }
  org.jivesoftware.smack.packet.IQ response;
  if (request instanceof ColibriConferenceIQ) {
    response=videobridge.handleColibriConferenceIQ((ColibriConferenceIQ)request);
  }
 else   if (request instanceof HealthCheckIQ) {
    response=videobridge.handleHealthCheckIQ((HealthCheckIQ)request);
  }
 else   if (request instanceof ShutdownIQ) {
    response=videobridge.handleShutdownIQ((ShutdownIQ)request);
  }
 else {
    response=null;
  }
  return response;
}
Program: 104988
Project: 104988
Buggy source:
/** 
 * Closes   {@link #transformEngine}. Normally this would be done by  {@link #stream} when it is being closed, but we have observed cases (e.g.when running health checks) where it doesn't happen, and since {@link #transformEngine} is part of this {@code RtpChannel}, the latter assumes the responsibility of releasing its resources.
 */
@Override public void expire(){
  if (getContent().getConference().includeInStatistics()) {
    Conference.Statistics conferenceStatistics=getContent().getConference().getStatistics();
    conferenceStatistics.totalChannels.incrementAndGet();
    long lastPayloadActivityTime=getLastPayloadActivityTime();
    long lastTransportActivityTime=getLastTransportActivityTime();
    if (lastTransportActivityTime == 0) {
      conferenceStatistics.totalNoTransportChannels.incrementAndGet();
    }
    if (lastPayloadActivityTime == 0) {
      conferenceStatistics.totalNoPayloadChannels.incrementAndGet();
    }
  }
  TransformEngine transformEngine=this.transformEngine;
  if (transformEngine != null) {
    PacketTransformer t=transformEngine.getRTPTransformer();
    if (t != null) {
      t.close();
    }
    t=transformEngine.getRTCPTransformer();
    if (t != null) {
      t.close();
    }
  }
  super.expire();
}

Fixed version (ground truth):
/** 
 * Closes   {@link #transformEngine}. Normally this would be done by  {@link #stream} when it is being closed, but we have observed cases (e.g.when running health checks) where it doesn't happen, and since {@link #transformEngine} is part of this {@code RtpChannel}, the latter assumes the responsibility of releasing its resources.
 */
@Override public boolean expire(){
  if (!super.expire()) {
    return false;
  }
  if (getContent().getConference().includeInStatistics()) {
    Conference.Statistics conferenceStatistics=getContent().getConference().getStatistics();
    conferenceStatistics.totalChannels.incrementAndGet();
    long lastPayloadActivityTime=getLastPayloadActivityTime();
    long lastTransportActivityTime=getLastTransportActivityTime();
    if (lastTransportActivityTime == 0) {
      conferenceStatistics.totalNoTransportChannels.incrementAndGet();
    }
    if (lastPayloadActivityTime == 0) {
      conferenceStatistics.totalNoPayloadChannels.incrementAndGet();
    }
  }
  TransformEngine transformEngine=this.transformEngine;
  if (transformEngine != null) {
    PacketTransformer t=transformEngine.getRTPTransformer();
    if (t != null) {
      t.close();
    }
    t=transformEngine.getRTCPTransformer();
    if (t != null) {
      t.close();
    }
  }
  return true;
}
Program: 104989
Project: 104989
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void expire(){
  try {
    eventDispatcher.shutdown();
  }
  finally {
    super.expire();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean expire(){
  if (!super.expire()) {
    return false;
  }
  eventDispatcher.shutdown();
  return true;
}
Program: 104990
Project: 104990
Buggy source:
/** 
 * {@inheritDoc}Closes the   {@link LastNController} before expiring the channel.
 */
@Override public void expire(){
  if (lastNController != null) {
    lastNController.close();
  }
  super.expire();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}Closes the   {@link LastNController} before expiring the channel.
 */
@Override public boolean expire(){
  if (!super.expire()) {
    return false;
  }
  if (lastNController != null) {
    lastNController.close();
  }
  return true;
}
Program: 104991
Project: 104991
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void run(){
synchronized (injectState) {
    if (!injectState.active || injectState.numOfKeyframesSent++ >= MAX_KEY_FRAMES) {
      scheduledFuture.cancel(true);
      return;
    }
    MediaStream mediaStream=injectState.target.get();
    if (mediaStream == null || !mediaStream.isStarted()) {
      logger.debug("String_Node_Str" + "String_Node_Str");
      return;
    }
    try {
      byte[] buf=KEY_FRAME_BUFFER.clone();
      RawPacket keyframe=new RawPacket(buf,0,buf.length);
      long timestamp=injectState.numOfKeyframesSent * 3000;
      keyframe.setSSRC(injectState.ssrc.intValue());
      keyframe.setSequenceNumber(injectState.numOfKeyframesSent);
      keyframe.setTimestamp(timestamp);
      logger.debug("String_Node_Str" + injectState.ssrc + "String_Node_Str"+ injectState.numOfKeyframesSent+ "String_Node_Str"+ timestamp);
      mediaStream.injectPacket(keyframe,true,null);
    }
 catch (    TransmissionFailedException e) {
      injectState.numOfKeyframesSent--;
      logger.error(e);
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void run(){
synchronized (injectState) {
    if (!injectState.active || injectState.numOfKeyframesSent >= MAX_KEY_FRAMES) {
      scheduledFuture.cancel(true);
      return;
    }
    MediaStream mediaStream=injectState.target.get();
    if (mediaStream == null || !mediaStream.isStarted()) {
      logger.debug("String_Node_Str" + "String_Node_Str");
      return;
    }
    try {
      injectState.numOfKeyframesSent++;
      byte[] buf=KEY_FRAME_BUFFER.clone();
      RawPacket keyframe=new RawPacket(buf,0,buf.length);
      long timestamp=injectState.numOfKeyframesSent * 3000;
      keyframe.setSSRC(injectState.ssrc.intValue());
      keyframe.setSequenceNumber(injectState.numOfKeyframesSent);
      keyframe.setTimestamp(timestamp);
      logger.debug("String_Node_Str" + injectState.ssrc + "String_Node_Str"+ injectState.numOfKeyframesSent+ "String_Node_Str"+ timestamp);
      mediaStream.injectPacket(keyframe,true,null);
    }
 catch (    TransmissionFailedException e) {
      injectState.numOfKeyframesSent--;
      logger.error(e);
    }
  }
}
Program: 104992
Project: 104992
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void receive(SimulcastStream simStream){
  if (simStream == null) {
    this.state=new State(null,null);
    return;
  }
  State oldState=this.state;
  SimulcastStream current=oldState.getCurrent();
  SimulcastStream next=oldState.getNext();
  if (current == simStream || next == simStream) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str");
    }
    return;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
  }
  simStream.askForKeyframe();
  if (current == null) {
    this.state=new State(new WeakReference<>(simStream),oldState.weakNext);
  }
 else {
    this.state=new State(oldState.weakCurrent,new WeakReference<>(simStream));
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void receive(SimulcastStream simStream){
  if (simStream == null) {
    this.state=new State(null,null);
    return;
  }
  State oldState=this.state;
  SimulcastStream current=oldState.getCurrent();
  SimulcastStream next=oldState.getNext();
  if (current == simStream) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
    }
    if (next != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
      }
      this.state=new State(new WeakReference<>(simStream),null);
    }
    return;
  }
  if (next == simStream) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
    }
    return;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
  }
  simStream.askForKeyframe();
  if (current == null) {
    this.state=new State(new WeakReference<>(simStream),oldState.weakNext);
  }
 else {
    this.state=new State(oldState.weakCurrent,new WeakReference<>(simStream));
  }
}
Program: 104993
Project: 104993
Buggy source:
/** 
 * Creates a   {@code RawPacket} which represents the original packetencapsulated in  {@code pkt} using the RTX format.
 * @param pkt the packet from which to extract a media packet.
 * @return the extracted media packet.
 */
private RawPacket createMediaPacket(RawPacket pkt){
  RawPacket mediaPacket=null;
  long rtxSsrc=pkt.getSSRCAsLong();
  RtpChannel sourceChannel=channel.getContent().findChannelByFidSsrc(rtxSsrc);
  if (sourceChannel != null) {
    long mediaSsrc=sourceChannel.getFidPairedSsrc(rtxSsrc);
    if (mediaSsrc != -1) {
      byte apt=sourceChannel.getRtxAssociatedPayloadType();
      if (apt != -1) {
        mediaPacket=new RawPacket(pkt.getBuffer().clone(),pkt.getOffset(),pkt.getLength());
        byte[] buf=mediaPacket.getBuffer();
        int off=mediaPacket.getOffset();
        System.arraycopy(buf,off,buf,off + 2,mediaPacket.getHeaderLength());
        mediaPacket.setOffset(off + 2);
        mediaPacket.setLength(pkt.getLength() - 2);
        mediaPacket.setSSRC((int)mediaSsrc);
        mediaPacket.setSequenceNumber(pkt.getOriginalSequenceNumber());
        mediaPacket.setPayloadType(apt);
      }
    }
  }
  return mediaPacket;
}

Fixed version (ground truth):
/** 
 * Creates a   {@code RawPacket} which represents the original packetencapsulated in  {@code pkt} using the RTX format.
 * @param pkt the packet from which to extract a media packet.
 * @return the extracted media packet.
 */
private RawPacket createMediaPacket(RawPacket pkt){
  RawPacket mediaPacket=null;
  long rtxSsrc=pkt.getSSRCAsLong();
  RtpChannel sourceChannel=channel.getContent().findChannelByFidSsrc(rtxSsrc);
  if (sourceChannel != null) {
    long mediaSsrc=sourceChannel.getFidPairedSsrc(rtxSsrc);
    if (mediaSsrc != -1) {
      byte apt=sourceChannel.getRtxAssociatedPayloadType();
      if (apt != -1) {
        mediaPacket=new RawPacket(pkt.getBuffer().clone(),pkt.getOffset(),pkt.getLength());
        byte[] buf=mediaPacket.getBuffer();
        int off=mediaPacket.getOffset();
        System.arraycopy(buf,off,buf,off + 2,mediaPacket.getHeaderLength());
        mediaPacket.setOffset(off + 2);
        mediaPacket.setLength(pkt.getLength() - 2);
        mediaPacket.setSSRC((int)mediaSsrc);
        mediaPacket.setSequenceNumber(pkt.getOriginalSequenceNumber());
        mediaPacket.setPayloadType(apt);
      }
 else {
        logger.warn("String_Node_Str" + "String_Node_Str" + rtxSsrc + "String_Node_Str"+ mediaSsrc);
      }
    }
  }
  return mediaPacket;
}
Program: 104994
Project: 104994
Buggy source:
/** 
 * Encapsulates   {@code pkt} in the RTX format, using {@code rtxSsrc} as itsSSRC, and transmits it to  {@link #channel} by injecting it in the{@code MediaStream}.
 * @param pkt the packet to transmit.
 * @param rtxSsrc the SSRC for the RTX stream.
 * @return {@code true} if the packet was successfully retransmitted,{@code false} otherwise.
 */
private boolean encapsulateInRtxAndTransmit(RawPacket pkt,long rtxSsrc){
  byte[] buf=pkt.getBuffer();
  int len=pkt.getLength();
  int off=pkt.getOffset();
  byte[] newBuf=buf;
  if (buf.length < len + 2) {
    newBuf=new byte[len + 2];
  }
  int osn=pkt.getSequenceNumber();
  int headerLength=pkt.getHeaderLength();
  int payloadLength=len - headerLength;
  System.arraycopy(buf,off,newBuf,0,headerLength);
  newBuf[headerLength]=(byte)((osn >> 8) & 0xff);
  newBuf[headerLength + 1]=(byte)(osn & 0xff);
  System.arraycopy(buf,off + headerLength,newBuf,headerLength + 2,payloadLength);
  MediaStream mediaStream=channel.getStream();
  if (mediaStream != null) {
    pkt.setSSRC((int)rtxSsrc);
    pkt.setSequenceNumber(getNextRtxSequenceNumber(rtxSsrc));
    try {
      mediaStream.injectPacket(pkt,true,null);
    }
 catch (    TransmissionFailedException tfe) {
      logger.warn("String_Node_Str");
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Encapsulates   {@code pkt} in the RTX format, using {@code rtxSsrc} as itsSSRC, and transmits it to  {@link #channel} by injecting it in the{@code MediaStream}.
 * @param pkt the packet to transmit.
 * @param rtxSsrc the SSRC for the RTX stream.
 * @param after the {@code TransformEngine} in the chain of{@code TransformEngine}s of the associated   {@code MediaStream} afterwhich the injection of  {@code pkt} is to begin
 * @return {@code true} if the packet was successfully retransmitted,{@code false} otherwise.
 */
private boolean encapsulateInRtxAndTransmit(RawPacket pkt,long rtxSsrc,TransformEngine after){
  byte[] buf=pkt.getBuffer();
  int len=pkt.getLength();
  int off=pkt.getOffset();
  byte[] newBuf=new byte[len + 2];
  RawPacket rtxPkt=new RawPacket(newBuf,0,len + 2);
  int osn=pkt.getSequenceNumber();
  int headerLength=pkt.getHeaderLength();
  int payloadLength=pkt.getPayloadLength();
  System.arraycopy(buf,off,newBuf,0,headerLength);
  newBuf[headerLength]=(byte)((osn >> 8) & 0xff);
  newBuf[headerLength + 1]=(byte)(osn & 0xff);
  System.arraycopy(buf,off + headerLength,newBuf,headerLength + 2,payloadLength);
  MediaStream mediaStream=channel.getStream();
  if (mediaStream != null) {
    rtxPkt.setSSRC((int)rtxSsrc);
    rtxPkt.setSequenceNumber(getNextRtxSequenceNumber(rtxSsrc));
    try {
      mediaStream.injectPacket(rtxPkt,true,after);
    }
 catch (    TransmissionFailedException tfe) {
      logger.warn("String_Node_Str");
      return false;
    }
  }
  return true;
}
Program: 104995
Project: 104995
Buggy source:
/** 
 * Retransmits a packet to   {@link #channel}. If the destination supports the RTX format, the packet will be encapsulated in RTX, otherwise, the packet will be retransmitted as-is.
 * @param pkt the packet to retransmit.
 * @param after the {@code TransformEngine} in the chain of{@code TransformEngine}s of the associated   {@code MediaStream} afterwhich the injection of  {@code pkt} is to begin
 * @return {@code true} if the packet was successfully retransmitted,{@code false} otherwise.
 */
public boolean retransmit(RawPacket pkt,TransformEngine after){
  boolean destinationSupportsRtx=channel.getRtxPayloadType() != -1;
  boolean retransmitPlain;
  if (destinationSupportsRtx) {
    long rtxSsrc=getPairedSsrc(pkt.getSSRCAsLong());
    if (rtxSsrc == -1) {
      logger.warn("String_Node_Str" + "String_Node_Str" + pkt.getSSRCAsLong());
      retransmitPlain=true;
    }
 else {
      retransmitPlain=!encapsulateInRtxAndTransmit(pkt,rtxSsrc);
    }
  }
 else {
    retransmitPlain=true;
  }
  if (retransmitPlain) {
    MediaStream mediaStream=channel.getStream();
    if (mediaStream != null) {
      try {
        mediaStream.injectPacket(pkt,true,after);
      }
 catch (      TransmissionFailedException tfe) {
        logger.warn("String_Node_Str");
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Retransmits a packet to   {@link #channel}. If the destination supports the RTX format, the packet will be encapsulated in RTX, otherwise, the packet will be retransmitted as-is.
 * @param pkt the packet to retransmit.
 * @param after the {@code TransformEngine} in the chain of{@code TransformEngine}s of the associated   {@code MediaStream} afterwhich the injection of  {@code pkt} is to begin
 * @return {@code true} if the packet was successfully retransmitted,{@code false} otherwise.
 */
public boolean retransmit(RawPacket pkt,TransformEngine after){
  boolean destinationSupportsRtx=channel.getRtxPayloadType() != -1;
  boolean retransmitPlain;
  if (destinationSupportsRtx) {
    long rtxSsrc=getPairedSsrc(pkt.getSSRCAsLong());
    if (rtxSsrc == -1) {
      logger.warn("String_Node_Str" + "String_Node_Str" + pkt.getSSRCAsLong());
      retransmitPlain=true;
    }
 else {
      retransmitPlain=!encapsulateInRtxAndTransmit(pkt,rtxSsrc,after);
    }
  }
 else {
    retransmitPlain=true;
  }
  if (retransmitPlain) {
    MediaStream mediaStream=channel.getStream();
    if (mediaStream != null) {
      try {
        mediaStream.injectPacket(pkt,true,after);
      }
 catch (      TransmissionFailedException tfe) {
        logger.warn("String_Node_Str");
        return false;
      }
    }
  }
  return true;
}
Program: 104996
Project: 104996
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean accept(RawPacket pkt){
  if (pkt == null) {
    return false;
  }
  State oldState=this.state;
  SimulcastStream next=oldState.getNext();
  if (next != null && next.matches(pkt) && next.isKeyFrame(pkt)) {
    int lastReceivedSeq=next.getLastPktSequenceNumber();
    int diff=RTPUtils.sequenceNumberDiff(pkt.getSequenceNumber(),lastReceivedSeq);
    if (diff >= 0) {
      this.state=new State(new WeakReference<>(next),null);
      return true;
    }
 else {
      logger.warn("String_Node_Str" + "String_Node_Str" + pkt.getSequenceNumber() + "String_Node_Str"+ lastReceivedSeq+ "String_Node_Str"+ pkt.getSSRCAsLong());
      next.askForKeyframe();
    }
  }
  SimulcastStream current=oldState.getCurrent();
  return current != null && current.matches(pkt);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean accept(RawPacket pkt){
  if (pkt == null) {
    return false;
  }
  State oldState=this.state;
  SimulcastStream next=oldState.getNext();
  Long pktSSRC=pkt.getSSRCAsLong();
  Integer pktSequenceNumber=pkt.getSequenceNumber();
  int diff=1;
  if (lastPktSequenceNumbers.containsKey(pktSSRC)) {
    int lastReceivedSeq=lastPktSequenceNumbers.get(pktSSRC);
    diff=RTPUtils.sequenceNumberDiff(pkt.getSequenceNumber(),lastReceivedSeq);
  }
  boolean accept=false;
  if (next != null && next.matches(pkt) && next.isKeyFrame(pkt)) {
    if (diff >= 0) {
      this.state=new State(new WeakReference<>(next),null);
      accept=true;
    }
 else {
      logger.warn("String_Node_Str" + "String_Node_Str" + pkt.getSequenceNumber() + "String_Node_Str"+ diff+ "String_Node_Str"+ pkt.getSSRCAsLong());
      next.askForKeyframe();
    }
  }
 else {
    SimulcastStream current=oldState.getCurrent();
    accept=current != null && current.matches(pkt);
  }
  if (diff >= 0) {
    lastPktSequenceNumbers.put(pktSSRC,pktSequenceNumber);
  }
  return accept;
}
Program: 104999
Project: 104999
Buggy source:
/** 
 * Notifies this instance about a change in the simulcast mode of the sending <tt>VideoChannel</tt>. We keep this in a separate method for readability and re-usability.
 * @param newMode
 * @param oldMode
 */
private void sendModeChanged(SimulcastMode newMode,SimulcastMode oldMode){
  if (newMode == null) {
    sendMode=null;
  }
 else   if (newMode == SimulcastMode.REWRITING) {
    sendMode=new RewritingSendMode(this);
  }
 else   if (newMode == SimulcastMode.SWITCHING) {
    sendMode=new SwitchingSendMode(this);
  }
  react(false);
}

Fixed version (ground truth):
/** 
 * Notifies this instance about a change in the simulcast mode of the sending <tt>VideoChannel</tt>. We keep this in a separate method for readability and re-usability.
 * @param newMode
 * @param oldMode
 */
private void sendModeChanged(SimulcastMode newMode,SimulcastMode oldMode){
  if (newMode == null) {
    sendMode=null;
    return;
  }
 else   if (newMode == SimulcastMode.REWRITING) {
    sendMode=new RewritingSendMode(this);
  }
 else   if (newMode == SimulcastMode.SWITCHING) {
    sendMode=new SwitchingSendMode(this);
  }
  this.sendMode.receive(targetOrder);
}
Program: 105001
Project: 105001
Buggy source:
@Override public void simulcastStreamsChanged(SimulcastStream... simulcastStreams){
  if (simulcastStreams == null || simulcastStreams.length == 0) {
    return;
  }
  SendMode sm=sendMode;
  if (sm == null) {
    return;
  }
  boolean isUrgent=false;
  for (  SimulcastStream l : simulcastStreams) {
    isUrgent=l == sm.getCurrent() && !l.isStreaming();
    if (isUrgent) {
      break;
    }
  }
  react(isUrgent);
}

Fixed version (ground truth):
@Override public void simulcastStreamsChanged(SimulcastStream... simulcastStreams){
  if (simulcastStreams == null || simulcastStreams.length == 0) {
    return;
  }
  SendMode sm=sendMode;
  if (sm == null) {
    return;
  }
  sm.receive(targetOrder);
}
Program: 105002
Project: 105002
Buggy source:
public String toJson(RewritingSendMode rewritingSendMode){
  if (rewritingSendMode == null) {
    return "String_Node_Str";
  }
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  SimulcastStream current=rewritingSendMode.getCurrent();
  if (current != null) {
    sb.append("String_Node_Str");
    toJson(sb,current);
    sb.append("String_Node_Str");
  }
  SimulcastStream next=rewritingSendMode.getNext();
  if (next != null) {
    sb.append("String_Node_Str");
    toJson(sb,next);
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
public void toJson(StringBuilder b,SimulcastStream simulcastStream){
  if (b == null || simulcastStream == null) {
    return;
  }
  b.append("String_Node_Str");
  b.append(Long.toString(simulcastStream.getPrimarySSRC()));
  b.append("String_Node_Str");
  b.append(Long.toString(simulcastStream.getRTXSSRC()));
  b.append("String_Node_Str");
  b.append(Boolean.toString(simulcastStream.isStreaming()));
  b.append("String_Node_Str");
}
Program: 105003
Project: 105003
Buggy source:
@Override public void receive(SimulcastStream simStream,boolean urgent){
  if (simStream == null) {
    weakCurrent=null;
    weakNext=null;
    return;
  }
  SimulcastStream current=getCurrent();
  SimulcastStream next=getNext();
  if (current == simStream || next == simStream) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str");
    }
    return;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ urgent+ "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
  }
  simStream.askForKeyframe();
  if (urgent || current == null) {
    weakCurrent=new WeakReference<>(simStream);
  }
 else {
    weakNext=new WeakReference<>(simStream);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void receive(SimulcastStream simStream){
  if (simStream == null) {
    this.state=new State(null,null);
    return;
  }
  State oldState=this.state;
  SimulcastStream current=oldState.weakCurrent != null ? oldState.weakCurrent.get() : null;
  SimulcastStream next=oldState.weakNext != null ? oldState.weakNext.get() : null;
  if (current == simStream || next == simStream) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str");
    }
    return;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + simStream.getOrder() + "String_Node_Str"+ getSimulcastSender().getSimulcastReceiver().getSimulcastEngine().getVideoChannel().getEndpoint().getID()+ "String_Node_Str");
  }
  simStream.askForKeyframe();
  if (current == null) {
    this.state=new State(new WeakReference<>(simStream),oldState.weakNext);
  }
 else {
    this.state=new State(oldState.weakCurrent,new WeakReference<>(simStream));
  }
}