nus-yam/ex-repair huggingface dataset:
Program: 103665
Project: 103665
Buggy source:
/** 
 * Creates the corresponding AdHocChatRoomParticipantPresenceChangeEvent and notifies all <tt>AdHocChatRoomParticipantPresenceListener</tt>s that a Contact has joined or left this <tt>AdHocChatRoom</tt>.
 * @param member the <tt>Contact</tt> that this
 * @param eventID the identifier of the event
 * @param eventReason the reason of the event
 */
private void fireParticipantPresenceEvent(Contact member,String eventID,String eventReason){
  AdHocChatRoomParticipantPresenceChangeEvent evt=new AdHocChatRoomParticipantPresenceChangeEvent(this,member,eventID,eventReason);
  logger.trace("String_Node_Str" + evt);
  Iterator<AdHocChatRoomParticipantPresenceListener> listeners=null;
synchronized (memberListeners) {
    listeners=new ArrayList<AdHocChatRoomParticipantPresenceListener>(memberListeners).iterator();
  }
  while (listeners.hasNext()) {
    AdHocChatRoomParticipantPresenceListener listener=listeners.next();
    listener.participantPresenceChanged(evt);
  }
}

Fixed version (ground truth):
/** 
 * Creates the corresponding AdHocChatRoomParticipantPresenceChangeEvent and notifies all <tt>AdHocChatRoomParticipantPresenceListener</tt>s that a Contact has joined or left this <tt>AdHocChatRoom</tt>.
 * @param member the <tt>Contact</tt> that this
 * @param eventID the identifier of the event
 * @param eventReason the reason of the event
 */
private void fireParticipantPresenceEvent(Contact member,String eventID,String eventReason){
  AdHocChatRoomParticipantPresenceChangeEvent evt=new AdHocChatRoomParticipantPresenceChangeEvent(this,member,eventID,eventReason);
  if (logger.isTraceEnabled())   logger.trace("String_Node_Str" + evt);
  Iterator<AdHocChatRoomParticipantPresenceListener> listeners=null;
synchronized (memberListeners) {
    listeners=new ArrayList<AdHocChatRoomParticipantPresenceListener>(memberListeners).iterator();
  }
  while (listeners.hasNext()) {
    AdHocChatRoomParticipantPresenceListener listener=listeners.next();
    listener.participantPresenceChanged(evt);
  }
}
Program: 103666
Project: 103666
Buggy source:
/** 
 * Sends the <tt>message</tt> to the destination indicated by the <tt>to</tt> contact.
 * @param message The <tt>Message</tt> to send.
 * @throws OperationFailedException if the underlying stack is notregistered or initialized or if the chat room is not joined.
 */
public void sendMessage(Message message) throws OperationFailedException {
  assertConnected();
  try {
    chatRoomSession.sendMessage(message.getContent());
    AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt=new AdHocChatRoomMessageDeliveredEvent(this,System.currentTimeMillis(),message,AdHocChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);
    fireMessageEvent(msgDeliveredEvt);
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str");
    throw new OperationFailedException("String_Node_Str",OperationFailedException.GENERAL_ERROR);
  }
}

Fixed version (ground truth):
/** 
 * Sends the <tt>message</tt> to the destination indicated by the <tt>to</tt> contact.
 * @param message The <tt>Message</tt> to send.
 * @throws OperationFailedException if the underlying stack is notregistered or initialized or if the chat room is not joined.
 */
public void sendMessage(Message message) throws OperationFailedException {
  assertConnected();
  try {
    chatRoomSession.sendMessage(message.getContent());
    AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt=new AdHocChatRoomMessageDeliveredEvent(this,System.currentTimeMillis(),message,AdHocChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);
    fireMessageEvent(msgDeliveredEvt);
  }
 catch (  Exception e) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    throw new OperationFailedException("String_Node_Str",OperationFailedException.GENERAL_ERROR);
  }
}
Program: 103667
Project: 103667
Buggy source:
/** 
 * Handles incoming messages for the specified chat room.
 * @param chatRoomSession Specific chat room session
 * @param chatRoomUser The User who sends the message
 * @param chatMessage The message
 */
public void handleIncomingMessage(ChatRoomSession chatRoomSession,ChatRoomUser chatRoomUser,ChatMessage chatMessage){
  logger.debug("String_Node_Str" + chatMessage.getMessage());
  String msgBody=chatMessage.getMessage();
  String msgContent;
  if (msgBody.startsWith(defaultHtmlStartTag)) {
    msgContent=msgBody.substring(msgBody.indexOf(defaultHtmlStartTag) + defaultHtmlStartTag.length(),msgBody.indexOf(defaultHtmlEndTag));
  }
 else   msgContent=msgBody;
  Message newMessage=createMessage(msgContent.getBytes(),HTML_MIME_TYPE,OperationSetBasicInstantMessagingIcqImpl.DEFAULT_MIME_ENCODING,null);
  String participantUID=chatRoomUser.getScreenname().getFormatted();
  if (participantUID.equals(nickName))   return;
  AdHocChatRoomMessageReceivedEvent msgReceivedEvent=new AdHocChatRoomMessageReceivedEvent(chatRoom,participants.get(participantUID),System.currentTimeMillis(),newMessage,AdHocChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED);
  fireMessageEvent(msgReceivedEvent);
}

Fixed version (ground truth):
/** 
 * Handles incoming messages for the specified chat room.
 * @param chatRoomSession Specific chat room session
 * @param chatRoomUser The User who sends the message
 * @param chatMessage The message
 */
public void handleIncomingMessage(ChatRoomSession chatRoomSession,ChatRoomUser chatRoomUser,ChatMessage chatMessage){
  if (logger.isDebugEnabled())   logger.debug("String_Node_Str" + chatMessage.getMessage());
  String msgBody=chatMessage.getMessage();
  String msgContent;
  if (msgBody.startsWith(defaultHtmlStartTag)) {
    msgContent=msgBody.substring(msgBody.indexOf(defaultHtmlStartTag) + defaultHtmlStartTag.length(),msgBody.indexOf(defaultHtmlEndTag));
  }
 else   msgContent=msgBody;
  Message newMessage=createMessage(msgContent.getBytes(),HTML_MIME_TYPE,OperationSetBasicInstantMessagingIcqImpl.DEFAULT_MIME_ENCODING,null);
  String participantUID=chatRoomUser.getScreenname().getFormatted();
  if (participantUID.equals(nickName))   return;
  AdHocChatRoomMessageReceivedEvent msgReceivedEvent=new AdHocChatRoomMessageReceivedEvent(chatRoom,participants.get(participantUID),System.currentTimeMillis(),newMessage,AdHocChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED);
  fireMessageEvent(msgReceivedEvent);
}
Program: 103668
Project: 103668
Buggy source:
/** 
 * Function called to refuse the file.
 */
public void rejectFile(){
  try {
    incomingFileTransfer.close();
    fileTransferOpSet.fireFileTransferRequestRejected(new FileTransferRequestEvent(fileTransferOpSet,this,date));
  }
 catch (  IllegalStateException e) {
    logger.debug("String_Node_Str",e);
    return;
  }
}

Fixed version (ground truth):
/** 
 * Function called to refuse the file.
 */
public void rejectFile(){
  try {
    incomingFileTransfer.close();
    fileTransferOpSet.fireFileTransferRequestRejected(new FileTransferRequestEvent(fileTransferOpSet,this,date));
  }
 catch (  IllegalStateException e) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",e);
    return;
  }
}
Program: 103669
Project: 103669
Buggy source:
public void waitForLastInfo(long waitFor){
synchronized (this) {
    try {
      wait(waitFor);
    }
 catch (    InterruptedException ex) {
      logger.debug("String_Node_Str",ex);
    }
  }
}

Fixed version (ground truth):
public void waitForLastInfo(long waitFor){
synchronized (this) {
    try {
      wait(waitFor);
    }
 catch (    InterruptedException ex) {
      if (logger.isDebugEnabled())       logger.debug("String_Node_Str",ex);
    }
  }
}
Program: 103670
Project: 103670
Buggy source:
/** 
 * The method is called by a ProtocolProvider implementation whenever a change in the registration state of the corresponding provider had occurred.
 * @param evt ProviderStatusChangeEvent the event describing the statuschange.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  logger.debug("String_Node_Str" + evt.getOldState() + "String_Node_Str"+ evt.getNewState());
  if (evt.getNewState() == RegistrationState.REGISTERED) {
    String customMessageEncoding=null;
    if ((customMessageEncoding=System.getProperty("String_Node_Str")) != null)     OscarTools.setDefaultCharset(customMessageEncoding);
    opSetPersPresence=(OperationSetPersistentPresenceIcqImpl)icqProvider.getOperationSet(OperationSetPersistentPresence.class);
    icqProvider.getAimConnection().getChatRoomManager().addListener(new ChatRoomManagerListenerImpl());
  }
}

Fixed version (ground truth):
/** 
 * The method is called by a ProtocolProvider implementation whenever a change in the registration state of the corresponding provider had occurred.
 * @param evt ProviderStatusChangeEvent the event describing the statuschange.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  if (logger.isDebugEnabled())   logger.debug("String_Node_Str" + evt.getOldState() + "String_Node_Str"+ evt.getNewState());
  if (evt.getNewState() == RegistrationState.REGISTERED) {
    String customMessageEncoding=null;
    if ((customMessageEncoding=System.getProperty("String_Node_Str")) != null)     OscarTools.setDefaultCharset(customMessageEncoding);
    opSetPersPresence=(OperationSetPersistentPresenceIcqImpl)icqProvider.getOperationSet(OperationSetPersistentPresence.class);
    icqProvider.getAimConnection().getChatRoomManager().addListener(new ChatRoomManagerListenerImpl());
  }
}
Program: 103671
Project: 103671
Buggy source:
public void handleInvitation(ChatRoomManager chatRoomManager,ChatInvitation chatInvitation){
  logger.debug("String_Node_Str" + chatInvitation.getRoomName());
  AdHocChatRoom chatRoom=createLocalChatRoomInstance(chatInvitation);
  invitations.put(chatRoom,chatInvitation);
  fireInvitationEvent(chatRoom,chatInvitation.getScreenname().toString(),chatInvitation.getMessage(),null);
}

Fixed version (ground truth):
public void handleInvitation(ChatRoomManager chatRoomManager,ChatInvitation chatInvitation){
  if (logger.isDebugEnabled())   logger.debug("String_Node_Str" + chatInvitation.getRoomName());
  AdHocChatRoom chatRoom=createLocalChatRoomInstance(chatInvitation);
  invitations.put(chatRoom,chatInvitation);
  fireInvitationEvent(chatRoom,chatInvitation.getScreenname().toString(),chatInvitation.getMessage(),null);
}
Program: 103672
Project: 103672
Buggy source:
/** 
 * Get the advanced format parameters list of our device that match remote supported ones.
 * @param remoteFormats remote advanced format parameters found in theSDP message
 * @param localFormats local advanced format parameters of our device
 * @return intersection between our local advanced parameters and remoteadvanced parameters
 */
private List<MediaFormat> getAdvancedFormatParameters(List<MediaFormat> remoteFormats,List<MediaFormat> localFormats){
  List<MediaFormat> ret=new ArrayList<MediaFormat>();
  for (  MediaFormat format : remoteFormats) {
    MediaFormat mf=findMediaFormat(localFormats,format.getEncoding());
    if (mf != null) {
      ret.add(mf);
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Gets the advanced format parameters list of our device that match remote supported ones.
 * @param remoteFormats remote advanced format parameters found in theSDP message
 * @param localFormats local advanced format parameters of our device
 * @return intersection between our local advanced parameters and remoteadvanced parameters
 */
private List<MediaFormat> getAdvancedFormatParameters(List<MediaFormat> remoteFormats,List<MediaFormat> localFormats){
  List<MediaFormat> ret=new ArrayList<MediaFormat>();
  for (  MediaFormat remoteFormat : remoteFormats) {
    MediaFormat localFormat=findMediaFormat(localFormats,remoteFormat);
    if (localFormat != null)     ret.add(localFormat);
  }
  return ret;
}
Program: 103673
Project: 103673
Buggy source:
/** 
 * Find a <tt>MediaFormat</tt> specified by its encoding in the list of <tt>MediaFormat</tt>.
 * @param formats list of <tt>MediaFormat</tt>
 * @param encoding encoding of the <tt>MediaFormat</tt> to find
 * @return <tt>MediaFormat</tt> if found in list of formats, nullotherwise
 */
private MediaFormat findMediaFormat(List<MediaFormat> formats,String encoding){
  for (  MediaFormat f : formats) {
    if (f.getEncoding().equals(encoding)) {
      return f;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Finds a <tt>MediaFormat</tt> in a specific list of <tt>MediaFormat</tt>s which matches a specific <tt>MediaFormat</tt>.
 * @param formats the list of <tt>MediaFormat</tt>s to find the specifiedmatching <tt>MediaFormat</tt> into
 * @param encoding encoding of the <tt>MediaFormat</tt> to find
 * @return the <tt>MediaFormat</tt> from <tt>formats</tt> which matches<tt>format</tt> if such a match exists in <tt>formats</tt>; otherwise, <tt>null</tt>
 */
private MediaFormat findMediaFormat(List<MediaFormat> formats,MediaFormat format){
  MediaType mediaType=format.getMediaType();
  String encoding=format.getEncoding();
  double clockRate=format.getClockRate();
  int channels=MediaType.AUDIO.equals(mediaType) ? ((AudioMediaFormat)format).getChannels() : MediaFormatFactory.CHANNELS_NOT_SPECIFIED;
  for (  MediaFormat match : formats) {
    if (AbstractMediaStream.matches(match,mediaType,encoding,clockRate,channels))     return match;
  }
  return null;
}
Program: 103674
Project: 103674
Buggy source:
/** 
 * Returns the dynamic payload type that has been allocated for <tt>format</tt>. A mapping for the specified <tt>format</tt> would be created even if it did not previously exist. The method is meant for use primarily during generation of SDP descriptions.
 * @param format the <tt>MediaFormat</tt> instance that we'd like to obtaina payload type number for..
 * @return the (possibly newly allocated) payload type number correspondingto the specified <tt>format</tt> instance for the lifetime of the media session.
 * @throws IllegalStateException if we have already registered more dynamicformats than allowed for by RTP.
 */
public byte obtainPayloadTypeNumber(MediaFormat format) throws IllegalStateException {
  Byte payloadType=payloadTypeMappings.get(format);
  if (payloadType == null) {
    payloadType=nextPayloadTypeNumber();
    payloadTypeMappings.put(format,payloadType);
  }
  return payloadType;
}

Fixed version (ground truth):
/** 
 * Returns the dynamic payload type that has been allocated for <tt>format</tt>. A mapping for the specified <tt>format</tt> would be created even if it did not previously exist. The method is meant for use primarily during generation of SDP descriptions.
 * @param format the <tt>MediaFormat</tt> instance that we'd like to obtaina payload type number for..
 * @return the (possibly newly allocated) payload type number correspondingto the specified <tt>format</tt> instance for the lifetime of the media session.
 * @throws IllegalStateException if we have already registered more dynamicformats than allowed for by RTP.
 */
public byte obtainPayloadTypeNumber(MediaFormat format) throws IllegalStateException {
  MediaType mediaType=format.getMediaType();
  String encoding=format.getEncoding();
  double clockRate=format.getClockRate();
  int channels=MediaType.AUDIO.equals(mediaType) ? ((AudioMediaFormat)format).getChannels() : MediaFormatFactory.CHANNELS_NOT_SPECIFIED;
  Byte payloadType=null;
  for (  Map.Entry<MediaFormat,Byte> payloadTypeMapping : payloadTypeMappings.entrySet()) {
    if (AbstractMediaStream.matches(payloadTypeMapping.getKey(),mediaType,encoding,clockRate,channels)) {
      payloadType=payloadTypeMapping.getValue();
      break;
    }
  }
  if (payloadType == null) {
    payloadType=nextPayloadTypeNumber();
    payloadTypeMappings.put(format,payloadType);
  }
  return payloadType;
}
Program: 103677
Project: 103677
Buggy source:
/** 
 * Returns a <tt>Map</tt> containing advanced parameters specific to this particular <MediaFormat</tt>. The parameters returned here are meant for use in SIP/SDP or XMPP session descriptions.
 * @return a <tt>Map</tt> containing advanced parameters specific to thisparticular <tt>MediaFormat</tt>
 */
public Map<String,String> getAdvancedAttributes();

Fixed version (ground truth):
/** 
 * Returns a <tt>Map</tt> containing advanced parameters specific to this particular <tt>MediaFormat</tt>. The parameters returned here are meant for use in SIP/SDP or XMPP session descriptions.
 * @return a <tt>Map</tt> containing advanced parameters specific to thisparticular <tt>MediaFormat</tt>
 */
public Map<String,String> getAdvancedAttributes();
Program: 103678
Project: 103678
Buggy source:
/** 
 * Reads audio data from this <tt>InputPortAudioStream</tt> into a specific <tt>Buffer</tt> blocking until audio data is indeed available.
 * @param buffer the <tt>Buffer</tt> into which the audio data read fromthis <tt>InputPortAudioStream</tt> is to be returned
 * @throws PortAudioException if an error occurs while reading
 */
public void read(Buffer buffer) throws PortAudioException {
  if (stopping || !started) {
    buffer.setLength(0);
    return;
  }
synchronized (readSync) {
    while (true) {
      if (bufferData == null) {
        if (!parentStream.read(buffer)) {
          try {
            readSync.wait();
          }
 catch (          InterruptedException e) {
            continue;
          }
          continue;
        }
      }
 else {
        Object data=buffer.getData();
        byte[] tmpArray;
        if (data instanceof byte[] && ((byte[])data).length >= bufferLength) {
          tmpArray=(byte[])data;
        }
 else {
          tmpArray=new byte[bufferLength];
          buffer.setData(tmpArray);
        }
        System.arraycopy(bufferData,0,tmpArray,0,bufferLength);
        buffer.setFlags(Buffer.FLAG_SYSTEM_TIME);
        buffer.setLength(bufferLength);
        buffer.setOffset(0);
        buffer.setTimeStamp(bufferTimeStamp);
      }
      break;
    }
    bufferData=null;
  }
}

Fixed version (ground truth):
/** 
 * Reads audio data from this <tt>InputPortAudioStream</tt> into a specific <tt>Buffer</tt> blocking until audio data is indeed available.
 * @param buffer the <tt>Buffer</tt> into which the audio data read fromthis <tt>InputPortAudioStream</tt> is to be returned
 * @throws PortAudioException if an error occurs while reading
 */
public void read(Buffer buffer) throws PortAudioException {
  if (stopping || !started) {
    buffer.setLength(0);
    return;
  }
synchronized (readSync) {
    while (true) {
      if (bufferData == null) {
        if (!parentStream.read(buffer)) {
          try {
            readSync.wait();
          }
 catch (          InterruptedException e) {
          }
          continue;
        }
      }
 else {
        Object data=buffer.getData();
        byte[] dataArray=null;
        if (data instanceof byte[]) {
          dataArray=(byte[])data;
          if (dataArray.length < bufferLength)           dataArray=null;
        }
        if (dataArray == null) {
          dataArray=new byte[bufferLength];
          buffer.setData(dataArray);
        }
        System.arraycopy(bufferData,0,dataArray,0,bufferLength);
        buffer.setFlags(Buffer.FLAG_SYSTEM_TIME);
        buffer.setLength(bufferLength);
        buffer.setOffset(0);
        buffer.setTimeStamp(bufferTimeStamp);
      }
      break;
    }
    bufferData=null;
  }
}
Program: 103679
Project: 103679
Buggy source:
/** 
 * Reads audio data from this <tt>MasterPortAudioStream</tt> into a specific <tt>Buffer</tt> blocking until audio data is indeed available.
 * @param buffer the <tt>Buffer</tt> into which the audio data read fromthis <tt>MasterPortAudioStream</tt> is to be returned
 * @throws PortAudioException if an error occurs while reading
 */
public boolean read(Buffer buffer) throws PortAudioException {
synchronized (readSync) {
    if (readActive) {
      return false;
    }
    readActive=true;
    if (!started) {
      buffer.setLength(0);
      return true;
    }
  }
  Object data=buffer.getData();
  byte[] bufferData;
  if (data instanceof byte[] && ((byte[])data).length >= bytesPerBuffer) {
    bufferData=(byte[])data;
  }
 else {
    bufferData=new byte[bytesPerBuffer];
    buffer.setData(bufferData);
  }
synchronized (connectedToStreamSync) {
    PortAudio.Pa_ReadStream(stream,bufferData,framesPerBuffer);
  }
  long bufferTimeStamp=System.nanoTime();
  buffer.setFlags(Buffer.FLAG_SYSTEM_TIME);
  buffer.setLength(bytesPerBuffer);
  buffer.setOffset(0);
  buffer.setTimeStamp(bufferTimeStamp);
  int slaveCount=slaves.size();
  for (int slaveIndex=0; slaveIndex < slaveCount; slaveIndex++) {
    slaves.get(slaveIndex).setBuffer(bufferData,bytesPerBuffer,bufferTimeStamp);
  }
synchronized (readSync) {
    readActive=false;
    readSync.notify();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Reads audio data from this <tt>MasterPortAudioStream</tt> into a specific <tt>Buffer</tt> blocking until audio data is indeed available.
 * @param buffer the <tt>Buffer</tt> into which the audio data read fromthis <tt>MasterPortAudioStream</tt> is to be returned
 * @throws PortAudioException if an error occurs while reading
 */
public boolean read(Buffer buffer) throws PortAudioException {
synchronized (readSync) {
    if (!started) {
      buffer.setLength(0);
      return true;
    }
    if (readActive)     return false;
    readActive=true;
  }
  try {
    Object data=buffer.getData();
    byte[] bufferData=null;
    if (data instanceof byte[]) {
      bufferData=(byte[])data;
      if (bufferData.length < bytesPerBuffer)       bufferData=null;
    }
    if (bufferData == null) {
      bufferData=new byte[bytesPerBuffer];
      buffer.setData(bufferData);
    }
synchronized (connectedToStreamSync) {
      PortAudio.Pa_ReadStream(stream,bufferData,framesPerBuffer);
    }
    long bufferTimeStamp=System.nanoTime();
    buffer.setFlags(Buffer.FLAG_SYSTEM_TIME);
    buffer.setLength(bytesPerBuffer);
    buffer.setOffset(0);
    buffer.setTimeStamp(bufferTimeStamp);
    int slaveCount=slaves.size();
    for (int slaveIndex=0; slaveIndex < slaveCount; slaveIndex++) {
      slaves.get(slaveIndex).setBuffer(bufferData,bytesPerBuffer,bufferTimeStamp);
    }
  }
  finally {
synchronized (readSync) {
      readActive=false;
      readSync.notify();
    }
  }
  return true;
}
Program: 103680
Project: 103680
Buggy source:
/** 
 * Stops the reading of a specific <tt>InputPortAudioStream</tt> from this <tt>MasterPortAudioStream</tt>. When the last such <tt>InputPortAudioStream</tt> stops reading from this instance, this instance closes the native PortAudio stream it reads from.
 * @param slave the <tt>InputPortAudioStream</tt> which has been stopped andno longer wants to read audio from this instance
 * @throws PortAudioException if anything wrong happens while stopping thenative PortAudio stream this instance reads from
 */
synchronized void stop(InputPortAudioStream slave) throws PortAudioException {
  if (!started)   return;
  slaves.remove(slave);
  if (slaves.isEmpty()) {
synchronized (readSync) {
      while (readActive) {
        try {
          readSync.wait();
        }
 catch (        InterruptedException e) {
          continue;
        }
      }
      PortAudio.Pa_CloseStream(stream);
      stream=0;
      started=false;
      PortAudioManager.getInstance().stoppedInputPortAudioStream(this);
    }
  }
}

Fixed version (ground truth):
/** 
 * Stops the reading of a specific <tt>InputPortAudioStream</tt> from this <tt>MasterPortAudioStream</tt>. When the last such <tt>InputPortAudioStream</tt> stops reading from this instance, this instance closes the native PortAudio stream it reads from.
 * @param slave the <tt>InputPortAudioStream</tt> which has been stopped andno longer wants to read audio from this instance
 * @throws PortAudioException if anything wrong happens while stopping thenative PortAudio stream this instance reads from
 */
synchronized void stop(InputPortAudioStream slave) throws PortAudioException {
  if (!started)   return;
  slaves.remove(slave);
  if (slaves.isEmpty()) {
synchronized (readSync) {
      while (readActive) {
        try {
          readSync.wait();
        }
 catch (        InterruptedException e) {
        }
      }
      PortAudio.Pa_CloseStream(stream);
      stream=0;
      started=false;
      PortAudioManager.getInstance().stoppedInputPortAudioStream(this);
    }
  }
}
Program: 103681
Project: 103681
Buggy source:
/** 
 * Reads audio data from this <tt>MasterPortAudioStream</tt> into a specific <tt>Buffer</tt> blocking until audio data is indeed available.
 * @param buffer the <tt>Buffer</tt> into which the audio data read fromthis <tt>MasterPortAudioStream</tt> is to be returned
 * @throws PortAudioException if an error occurs while reading
 */
public boolean read(Buffer buffer) throws PortAudioException {
synchronized (readSync) {
    if (!started) {
      buffer.setLength(0);
      return true;
    }
    if (readActive)     return false;
    readActive=true;
  }
  try {
    Object data=buffer.getData();
    byte[] bufferData=null;
    if (data instanceof byte[]) {
      bufferData=(byte[])data;
      if (bufferData.length < bytesPerBuffer)       bufferData=null;
    }
    if (bufferData == null) {
      bufferData=new byte[bytesPerBuffer];
      buffer.setData(bufferData);
    }
synchronized (connectedToStreamSync) {
      PortAudio.Pa_ReadStream(stream,bufferData,framesPerBuffer);
    }
    long bufferTimeStamp=System.nanoTime();
    buffer.setFlags(Buffer.FLAG_SYSTEM_TIME);
    buffer.setLength(bytesPerBuffer);
    buffer.setOffset(0);
    buffer.setTimeStamp(bufferTimeStamp);
    int slaveCount=slaves.size();
    for (int slaveIndex=0; slaveIndex < slaveCount; slaveIndex++) {
      slaves.get(slaveIndex).setBuffer(bufferData,bytesPerBuffer,bufferTimeStamp);
    }
  }
  finally {
synchronized (readSync) {
      readActive=false;
      readSync.notify();
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Reads audio data from this <tt>MasterPortAudioStream</tt> into a specific <tt>Buffer</tt> blocking until audio data is indeed available.
 * @param buffer the <tt>Buffer</tt> into which the audio data read fromthis <tt>MasterPortAudioStream</tt> is to be returned
 * @throws PortAudioException if an error occurs while reading
 */
public boolean read(Buffer buffer) throws PortAudioException {
synchronized (readSync) {
    if (!started) {
      buffer.setLength(0);
      return true;
    }
    if (readActive)     return false;
    readActive=true;
  }
  try {
    Object data=buffer.getData();
    byte[] bufferData=null;
    if (data instanceof byte[]) {
      bufferData=(byte[])data;
      if (bufferData.length < bytesPerBuffer)       bufferData=null;
    }
    if (bufferData == null) {
      bufferData=new byte[bytesPerBuffer];
      buffer.setData(bufferData);
    }
synchronized (connectedToStreamSync) {
      PortAudio.Pa_ReadStream(stream,bufferData,framesPerBuffer);
    }
    long bufferTimeStamp=System.nanoTime();
    buffer.setFlags(Buffer.FLAG_SYSTEM_TIME);
    buffer.setLength(bytesPerBuffer);
    buffer.setOffset(0);
    buffer.setTimeStamp(bufferTimeStamp);
    int slaveCount=slaves.size();
    for (int slaveIndex=0; slaveIndex < slaveCount; slaveIndex++) {
      slaves.get(slaveIndex).setBuffer(bufferData,bytesPerBuffer,bufferTimeStamp);
    }
  }
  finally {
synchronized (readSync) {
      readActive=false;
      readSync.notifyAll();
    }
  }
  return true;
}
Program: 103682
Project: 103682
Buggy source:
/** 
 * Stops the reading of a specific <tt>InputPortAudioStream</tt> from this <tt>MasterPortAudioStream</tt>. When the last such <tt>InputPortAudioStream</tt> stops reading from this instance, this instance closes the native PortAudio stream it reads from.
 * @param slave the <tt>InputPortAudioStream</tt> which has been stopped andno longer wants to read audio from this instance
 * @throws PortAudioException if anything wrong happens while stopping thenative PortAudio stream this instance reads from
 */
synchronized void stop(InputPortAudioStream slave) throws PortAudioException {
  if (!started)   return;
  slaves.remove(slave);
  if (slaves.isEmpty()) {
synchronized (readSync) {
      while (readActive) {
        try {
          readSync.wait();
        }
 catch (        InterruptedException e) {
        }
      }
      PortAudio.Pa_CloseStream(stream);
      stream=0;
      started=false;
      PortAudioManager.getInstance().stoppedInputPortAudioStream(this);
    }
  }
}

Fixed version (ground truth):
/** 
 * Stops the reading of a specific <tt>InputPortAudioStream</tt> from this <tt>MasterPortAudioStream</tt>. When the last such <tt>InputPortAudioStream</tt> stops reading from this instance, this instance closes the native PortAudio stream it reads from.
 * @param slave the <tt>InputPortAudioStream</tt> which has been stopped andno longer wants to read audio from this instance
 * @throws PortAudioException if anything wrong happens while stopping thenative PortAudio stream this instance reads from
 */
synchronized void stop(InputPortAudioStream slave) throws PortAudioException {
  if (!started)   return;
  slaves.remove(slave);
  if (slaves.isEmpty()) {
synchronized (readSync) {
      while (readActive) {
        try {
          readSync.wait(100);
        }
 catch (        InterruptedException e) {
        }
      }
      PortAudio.Pa_CloseStream(stream);
      stream=0;
      started=false;
      PortAudioManager.getInstance().stoppedInputPortAudioStream(this);
    }
  }
}
Program: 103683
Project: 103683
Buggy source:
/** 
 * Creates the <tt>SearchField</tt>.
 * @param frame the main application window
 */
public SearchField(MainFrame frame){
  super(GuiActivator.getResources().getI18NString("String_Node_Str"));
  this.mainFrame=frame;
  SearchFieldUI textFieldUI=new SearchFieldUI();
  textFieldUI.setDeleteButtonEnabled(true);
  this.setUI(textFieldUI);
  this.setBorder(null);
  this.setOpaque(false);
  this.setPreferredSize(new Dimension(100,22));
  this.setDragEnabled(true);
  this.addTextChangeListener(this);
  InputMap imap=getInputMap(JComponent.WHEN_FOCUSED);
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),"String_Node_Str");
  ActionMap amap=getActionMap();
  amap.put("String_Node_Str",new AbstractAction(){
    public void actionPerformed(    ActionEvent e){
      setText("String_Node_Str");
      SearchField.this.mainFrame.requestFocusInCenterPanel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates the <tt>SearchField</tt>.
 * @param frame the main application window
 */
public SearchField(MainFrame frame){
  super(GuiActivator.getResources().getI18NString("String_Node_Str"));
  this.mainFrame=frame;
  SearchFieldUI textFieldUI=new SearchFieldUI();
  textFieldUI.setDeleteButtonEnabled(true);
  this.setUI(textFieldUI);
  this.setBorder(null);
  this.setOpaque(false);
  this.setPreferredSize(new Dimension(100,22));
  this.setDragEnabled(true);
  this.addTextChangeListener(this);
  InputMap imap=getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),"String_Node_Str");
  ActionMap amap=getActionMap();
  amap.put("String_Node_Str",new AbstractAction(){
    public void actionPerformed(    ActionEvent e){
      setText("String_Node_Str");
      SearchField.this.mainFrame.requestFocusInCenterPanel();
    }
  }
);
}
Program: 103684
Project: 103684
Buggy source:
/** 
 * Starts the <tt>SendStream</tt>s of the <tt>RTPManager</tt> of this <tt>MediaStream</tt>.
 */
private void startSendStreams(){
  if (!sendStreamsAreCreated)   createSendStreams();
  RTPManager rtpManager=getRTPManager();
  @SuppressWarnings("String_Node_Str") Iterable<SendStream> sendStreams=rtpManager.getSendStreams();
  if (sendStreams != null)   for (  SendStream sendStream : sendStreams)   try {
    sendStream.getDataSource().connect();
    sendStream.start();
    sendStream.getDataSource().start();
    if (logger.isTraceEnabled())     logger.trace("String_Node_Str" + "String_Node_Str" + sendStream.hashCode());
  }
 catch (  IOException ioe) {
    logger.warn("String_Node_Str" + sendStream,ioe);
  }
}

Fixed version (ground truth):
/** 
 * Starts the <tt>SendStream</tt>s of the <tt>RTPManager</tt> of this <tt>MediaStreamImpl</tt>.
 */
private void startSendStreams(){
  if (!sendStreamsAreCreated)   createSendStreams();
  RTPManager rtpManager=getRTPManager();
  @SuppressWarnings("String_Node_Str") Iterable<SendStream> sendStreams=rtpManager.getSendStreams();
  if (sendStreams != null) {
    for (    SendStream sendStream : sendStreams) {
      try {
        sendStream.getDataSource().connect();
        sendStream.start();
        sendStream.getDataSource().start();
        if (logger.isTraceEnabled()) {
          logger.trace("String_Node_Str" + sendStream.hashCode());
        }
      }
 catch (      IOException ioe) {
        logger.warn("String_Node_Str" + sendStream,ioe);
      }
    }
  }
}
Program: 103686
Project: 103686
Buggy source:
/** 
 * The <tt>ZrtpControl</tt> which controls the ZRTP for the current stream.
 * @return the <tt>ZrtpControl</tt> for the current stream.
 */
public ZrtpControl getZrtpControl(){
  return zrtpControl;
}

Fixed version (ground truth):
/** 
 * Gets the <tt>ZrtpControl</tt> which controls the ZRTP of this stream.
 * @return the <tt>ZrtpControl</tt> which controls the ZRTP of this stream
 */
public ZrtpControl getZrtpControl(){
  return zrtpControl;
}
Program: 103689
Project: 103689
Buggy source:
/** 
 * Action when shoe certificate button is clicked.
 */
private void actionShowCertificate(){
  if (certOpened) {
    certPanel.removeAll();
    certButton.setText(GuiActivator.getResources().getI18NString("String_Node_Str"));
    certPanel.revalidate();
    certPanel.repaint();
    pack();
    certOpened=false;
    setLocationRelativeTo(getParent());
    return;
  }
  certPanel.setLayout(new BorderLayout());
  certPanel.add(alwaysTrustCheckBox,BorderLayout.NORTH);
  Component certInfoPane=null;
  if (cert instanceof X509Certificate) {
    certInfoPane=getX509DisplayComponent((X509Certificate)cert);
  }
 else {
    JTextArea textArea=new JTextArea();
    textArea.setEditable(false);
    textArea.setText(cert.toString());
    certInfoPane=textArea;
  }
  final JScrollPane certScroll=new JScrollPane(certInfoPane);
  certScroll.setPreferredSize(new Dimension(300,300));
  certPanel.add(certScroll,BorderLayout.CENTER);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      certScroll.getVerticalScrollBar().setValue(0);
    }
  }
);
  certButton.setText(GuiActivator.getResources().getI18NString("String_Node_Str"));
  certPanel.revalidate();
  certPanel.repaint();
  setPreferredSize(null);
  pack();
  certOpened=true;
  setLocationRelativeTo(getParent());
}

Fixed version (ground truth):
/** 
 * Action when shoe certificate button is clicked.
 */
private void actionShowCertificate(){
  if (certOpened) {
    certPanel.removeAll();
    certButton.setText(GuiActivator.getResources().getI18NString("String_Node_Str"));
    certPanel.revalidate();
    certPanel.repaint();
    pack();
    certOpened=false;
    setLocationRelativeTo(getParent());
    return;
  }
  certPanel.setLayout(new BorderLayout());
  certPanel.add(alwaysTrustCheckBox,BorderLayout.NORTH);
  Component certInfoPane=null;
  if (cert instanceof X509Certificate) {
    certInfoPane=getX509DisplayComponent((X509Certificate)cert);
  }
 else {
    JTextArea textArea=new JTextArea();
    textArea.setOpaque(false);
    textArea.setEditable(false);
    textArea.setText(cert.toString());
    certInfoPane=textArea;
  }
  final JScrollPane certScroll=new JScrollPane(certInfoPane);
  certScroll.setPreferredSize(new Dimension(300,300));
  certPanel.add(certScroll,BorderLayout.CENTER);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      certScroll.getVerticalScrollBar().setValue(0);
    }
  }
);
  certButton.setText(GuiActivator.getResources().getI18NString("String_Node_Str"));
  certPanel.revalidate();
  certPanel.repaint();
  setPreferredSize(null);
  pack();
  certOpened=true;
  setLocationRelativeTo(getParent());
}
Program: 103691
Project: 103691
Buggy source:
/** 
 * Enters or exits the "unknown contact" view. This view will propose to the user some specific operations if the current filter doesn't match any contacts.
 * @param isEnabled <tt>true</tt> to enable the "unknown contact" view,<tt>false</tt> - otherwise.
 */
public void enableUnknownContactView(boolean isEnabled){
  if (isEnabled) {
    if (unknownContactPanel == null)     unknownContactPanel=new UnknownContactPanel(this);
    centerPanel.remove(contactListPanel);
    centerPanel.add(unknownContactPanel,BorderLayout.CENTER);
  }
 else   if (unknownContactPanel != null) {
    centerPanel.remove(unknownContactPanel);
    centerPanel.add(contactListPanel,BorderLayout.CENTER);
  }
  centerPanel.revalidate();
  centerPanel.repaint();
}

Fixed version (ground truth):
/** 
 * Enters or exits the "unknown contact" view. This view will propose to the user some specific operations if the current filter doesn't match any contacts.
 * @param isEnabled <tt>true</tt> to enable the "unknown contact" view,<tt>false</tt> - otherwise.
 */
public void enableUnknownContactView(boolean isEnabled){
  if (isEnabled) {
    if (unknownContactPanel == null)     unknownContactPanel=new UnknownContactPanel(this);
    contactListPanel.setVisible(false);
    unknownContactPanel.setVisible(true);
    centerPanel.remove(contactListPanel);
    centerPanel.add(unknownContactPanel,BorderLayout.CENTER);
  }
 else   if (unknownContactPanel != null) {
    unknownContactPanel.setVisible(false);
    contactListPanel.setVisible(true);
    centerPanel.remove(unknownContactPanel);
    centerPanel.add(contactListPanel,BorderLayout.CENTER);
  }
  centerPanel.revalidate();
  centerPanel.repaint();
}
Program: 103693
Project: 103693
Buggy source:
/** 
 * Initializes and add some common components.
 */
private void init(){
  setInvoker(invoker);
  this.add(createInfoLabel());
  this.addSeparator();
}

Fixed version (ground truth):
/** 
 * Initializes and add some common components.
 */
private void init(){
  setInvoker(invoker);
  this.add(createInfoLabel());
  this.addSeparator();
  this.setFocusable(true);
}
Program: 103694
Project: 103694
Buggy source:
/** 
 * Initializes the contact list.
 * @param contactListService The MetaContactListService which will be usedfor a contact list data model.
 */
public void initList(MetaContactListService contactListService){
  this.contactList=new TreeContactList();
  GuiActivator.setContactList(contactList);
  TransparentPanel transparentPanel=new TransparentPanel(new BorderLayout());
  transparentPanel.add(contactList,BorderLayout.NORTH);
  this.setViewportView(transparentPanel);
  transparentPanel.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
  this.contactList.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
  this.contactList.addContactListListener(this);
  this.addMouseListener(new MouseAdapter(){
    public void mousePressed(    MouseEvent e){
      if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
        commonRightButtonMenu=new CommonRightButtonMenu(mainFrame);
        commonRightButtonMenu.setInvoker(ContactListPane.this);
        commonRightButtonMenu.setLocation(e.getX() + mainFrame.getX() + 5,e.getY() + mainFrame.getY() + 105);
        commonRightButtonMenu.setVisible(true);
      }
    }
  }
);
  this.getActionMap().put("String_Node_Str",new ContactListPanelEnterAction());
  InputMap imap=this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Initializes the contact list.
 * @param contactListService The MetaContactListService which will be usedfor a contact list data model.
 */
public void initList(MetaContactListService contactListService){
  this.contactList=new TreeContactList();
  GuiActivator.setContactList(contactList);
  TransparentPanel transparentPanel=new TransparentPanel(new BorderLayout());
  transparentPanel.add(contactList,BorderLayout.NORTH);
  this.setViewportView(transparentPanel);
  transparentPanel.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
  this.contactList.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
  this.contactList.addContactListListener(this);
  this.addMouseListener(new MouseAdapter(){
    public void mousePressed(    MouseEvent e){
      if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
        commonRightButtonMenu=new CommonRightButtonMenu(mainFrame);
        commonRightButtonMenu.setInvoker(ContactListPane.this);
        commonRightButtonMenu.setLocation(e.getX() + mainFrame.getX() + 5,e.getY() + mainFrame.getY() + 105);
        commonRightButtonMenu.setVisible(true);
      }
    }
  }
);
}
Program: 103696
Project: 103696
Buggy source:
public void actionPerformed(ActionEvent e){
  if (!lastHasMatching)   CallManager.createCall(getText());
 else   GuiActivator.getContactList().startSelectedContactChat();
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent e){
  setText("String_Node_Str");
  SearchField.this.mainFrame.requestFocusInCenterPanel();
}
Program: 103697
Project: 103697
Buggy source:
/** 
 * Creates the <tt>SearchField</tt>.
 * @param mainFrame the main application window
 */
public SearchField(MainFrame mainFrame){
  super(GuiActivator.getResources().getI18NString("String_Node_Str"));
  this.mainFrame=mainFrame;
  SearchTextFieldUI textFieldUI=new SearchTextFieldUI();
  textFieldUI.setDeleteButtonEnabled(true);
  this.setUI(textFieldUI);
  this.setBorder(null);
  this.setOpaque(false);
  this.setPreferredSize(new Dimension(100,22));
  this.setDragEnabled(true);
  this.getDocument().addDocumentListener(this);
  InputMap imap=getInputMap(JComponent.WHEN_FOCUSED);
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),"String_Node_Str");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0),"String_Node_Str");
  ActionMap amap=getActionMap();
  amap.put("String_Node_Str",new AbstractAction(){
    public void actionPerformed(    ActionEvent e){
      setText("String_Node_Str");
      SearchField.this.mainFrame.requestFocusInCenterPanel();
    }
  }
);
  amap.put("String_Node_Str",new AbstractAction(){
    public void actionPerformed(    ActionEvent e){
      if (!lastHasMatching)       CallManager.createCall(getText());
 else       GuiActivator.getContactList().startSelectedContactChat();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates the <tt>SearchField</tt>.
 * @param frame the main application window
 */
public SearchField(MainFrame frame){
  super(GuiActivator.getResources().getI18NString("String_Node_Str"));
  this.mainFrame=frame;
  SearchTextFieldUI textFieldUI=new SearchTextFieldUI();
  textFieldUI.setDeleteButtonEnabled(true);
  this.setUI(textFieldUI);
  this.setBorder(null);
  this.setOpaque(false);
  this.setPreferredSize(new Dimension(100,22));
  this.setDragEnabled(true);
  this.getDocument().addDocumentListener(this);
  InputMap imap=getInputMap(JComponent.WHEN_FOCUSED);
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),"String_Node_Str");
  ActionMap amap=getActionMap();
  amap.put("String_Node_Str",new AbstractAction(){
    public void actionPerformed(    ActionEvent e){
      setText("String_Node_Str");
      SearchField.this.mainFrame.requestFocusInCenterPanel();
    }
  }
);
}
Program: 103698
Project: 103698
Buggy source:
/** 
 * Ends the registration of this protocol provider with the current registration service.
 * @throws OperationFailedException with the corresponding code it theregistration fails for some reason (e.g. a networking error or an implementation problem).
 */
public void unregister() throws OperationFailedException {
  if (getRegistrationState().equals(RegistrationState.UNREGISTERED) || getRegistrationState().equals(RegistrationState.UNREGISTERING)) {
    return;
  }
  sipRegistrarConnection.unregister();
  sipSecurityManager.setSecurityAuthority(null);
}

Fixed version (ground truth):
/** 
 * Ends the registration of this protocol provider with the current registration service.
 * @throws OperationFailedException with the corresponding code it theregistration fails for some reason (e.g. a networking error or an implementation problem).
 */
public void unregister() throws OperationFailedException {
  if (getRegistrationState().equals(RegistrationState.UNREGISTERED) || getRegistrationState().equals(RegistrationState.UNREGISTERING) || getRegistrationState().equals(RegistrationState.CONNECTION_FAILED)) {
    return;
  }
  sipRegistrarConnection.unregister();
  sipSecurityManager.setSecurityAuthority(null);
}
Program: 103699
Project: 103699
Buggy source:
/** 
 * Creates a media <tt>StreamConnector</tt>. The method takes into account the minimum and maximum media port boundaries.
 * @return a new <tt>StreamConnector</tt>.
 * @throws OperationFailedException if we fail binding the the sockets.
 */
private StreamConnector createStreamConnector() throws OperationFailedException {
  NetworkAddressManagerService nam=SipActivator.getNetworkAddressManagerService();
  InetAddress intendedDestination=peer.getProtocolProvider().getIntendedDestination(peer.getPeerAddress());
  InetAddress localHostForPeer=nam.getLocalHost(intendedDestination);
  initializePortNumbers();
  DatagramSocket rtpSocket=null;
  try {
    rtpSocket=nam.createDatagramSocket(localHostForPeer,nextMediaPortToTry,minMediaPort,maxMediaPort);
  }
 catch (  Exception exc) {
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,exc,logger);
  }
  nextMediaPortToTry=rtpSocket.getLocalPort() + 1;
  DatagramSocket rtcpSocket=null;
  try {
    rtcpSocket=nam.createDatagramSocket(localHostForPeer,nextMediaPortToTry,minMediaPort,maxMediaPort);
  }
 catch (  Exception exc) {
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,exc,logger);
  }
  nextMediaPortToTry=rtcpSocket.getLocalPort() + 1;
  DefaultStreamConnector connector=new DefaultStreamConnector(rtpSocket,rtcpSocket);
  return connector;
}

Fixed version (ground truth):
/** 
 * Creates a media <tt>StreamConnector</tt>. The method takes into account the minimum and maximum media port boundaries.
 * @return a new <tt>StreamConnector</tt>.
 * @throws OperationFailedException if we fail binding the the sockets.
 */
private StreamConnector createStreamConnector() throws OperationFailedException {
  NetworkAddressManagerService nam=SipActivator.getNetworkAddressManagerService();
  InetAddress intendedDestination=peer.getProtocolProvider().getIntendedDestination(peer.getPeerAddress());
  InetAddress localHostForPeer=nam.getLocalHost(intendedDestination);
  initializePortNumbers();
  DatagramSocket rtpSocket=null;
  try {
    rtpSocket=nam.createDatagramSocket(localHostForPeer,nextMediaPortToTry,minMediaPort,maxMediaPort);
  }
 catch (  Exception exc) {
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,exc,logger);
  }
  nextMediaPortToTry=rtpSocket.getLocalPort() + 1;
  DatagramSocket rtcpSocket=null;
  try {
    rtcpSocket=nam.createDatagramSocket(localHostForPeer,nextMediaPortToTry,minMediaPort,maxMediaPort);
  }
 catch (  Exception exc) {
    ProtocolProviderServiceSipImpl.throwOperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,exc,logger);
  }
  nextMediaPortToTry=rtcpSocket.getLocalPort() + 1;
  if (nextMediaPortToTry > maxMediaPort)   nextMediaPortToTry=minMediaPort;
  DefaultStreamConnector connector=new DefaultStreamConnector(rtpSocket,rtcpSocket);
  return connector;
}