nus-yam/ex-repair huggingface dataset:
Program: 104391
Project: 104391
Buggy source:
/** 
 * Creates a room with the named <tt>roomName</tt> and according to the specified <tt>roomProperties</tt> on the server that this protocol provider is currently connected to. When the method returns the room the local user will not have joined it and thus will not receive messages on it until the <tt>ChatRoom.join()</tt> method is called. <p>
 * @param roomName the name of the <tt>ChatRoom</tt> to create.
 * @param roomProperties properties specifying how the room should becreated.
 * @throws OperationFailedException if the room couldn't be created for somereason (e.g. room already exists; user already joined to an existant room or user has no permissions to create a chat room).
 * @throws OperationNotSupportedException if chat room creation is notsupported by this server
 * @return the newly created <tt>ChatRoom</tt> named <tt>roomName</tt>.
 */
public ChatRoom createChatRoom(String roomName,Hashtable roomProperties) throws OperationFailedException, OperationNotSupportedException ;

Fixed version (ground truth):
/** 
 * Creates a room with the named <tt>roomName</tt> and according to the specified <tt>roomProperties</tt> on the server that this protocol provider is currently connected to. When the method returns the room the local user will not have joined it and thus will not receive messages on it until the <tt>ChatRoom.join()</tt> method is called. <p>
 * @param roomName the name of the <tt>ChatRoom</tt> to create.
 * @param roomProperties properties specifying how the room should becreated.
 * @throws OperationFailedException if the room couldn't be created for somereason (e.g. room already exists; user already joined to an existent room or user has no permissions to create a chat room).
 * @throws OperationNotSupportedException if chat room creation is notsupported by this server
 * @return the newly created <tt>ChatRoom</tt> named <tt>roomName</tt>.
 */
public ChatRoom createChatRoom(String roomName,Hashtable roomProperties) throws OperationFailedException, OperationNotSupportedException ;
Program: 104396
Project: 104396
Buggy source:
private void ensureDocumentSize(){
  if (document.getLength() > Constants.CHAT_BUFFER_SIZE && document.getDefaultRootElement().getElementCount() > 2) {
    Element firstElement=this.document.getDefaultRootElement().getElement(0);
    try {
      if (firstElement != null)       this.document.remove(firstElement.getStartOffset(),firstElement.getEndOffset() - firstElement.getStartOffset());
      String idAttr=(String)firstElement.getAttributes().getAttribute("String_Node_Str");
      if (idAttr != null && idAttr.equals("String_Node_Str")) {
        Element secondElement=this.document.getDefaultRootElement().getElement(0);
        this.document.remove(secondElement.getStartOffset(),secondElement.getEndOffset() - secondElement.getStartOffset());
      }
    }
 catch (    BadLocationException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Ensures that the document won't become too big. When the document reaches a certain size the first message in the page is removed.
 */
private void ensureDocumentSize(){
  if (document.getLength() > Constants.CHAT_BUFFER_SIZE) {
    int msgElementCount=0;
    Element firstMsgElement=null;
    int firstMsgIndex=0;
    Element rootElement=this.document.getDefaultRootElement();
    for (int i=0; i < rootElement.getElementCount(); i++) {
      String idAttr=(String)rootElement.getElement(i).getAttributes().getAttribute("String_Node_Str");
      if (idAttr != null && (idAttr.equals("String_Node_Str") || idAttr.equals("String_Node_Str") || idAttr.equals("String_Node_Str"))) {
        if (firstMsgElement == null) {
          firstMsgElement=rootElement.getElement(i);
          firstMsgIndex=i;
        }
        msgElementCount++;
      }
    }
    if (firstMsgElement == null || msgElementCount < 2)     return;
    try {
      Element headerElement=null;
      if (firstMsgIndex > 1) {
        headerElement=rootElement.getElement(firstMsgIndex - 1);
        String idAttr=(String)headerElement.getAttributes().getAttribute("String_Node_Str");
        if (idAttr != null && idAttr.equals("String_Node_Str")) {
          this.document.remove(headerElement.getStartOffset(),headerElement.getEndOffset() - headerElement.getStartOffset());
        }
      }
      this.document.remove(firstMsgElement.getStartOffset(),firstMsgElement.getEndOffset() - firstMsgElement.getStartOffset());
    }
 catch (    BadLocationException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
}
Program: 104397
Project: 104397
Buggy source:
private void ensureDocumentSize(){
  if (document.getLength() > Constants.CHAT_BUFFER_SIZE) {
    Element firstElement=this.document.getDefaultRootElement().getElement(0);
    try {
      if (firstElement != null)       this.document.remove(firstElement.getStartOffset(),firstElement.getEndOffset() - firstElement.getStartOffset());
      String idAttr=(String)firstElement.getAttributes().getAttribute("String_Node_Str");
      if (idAttr != null && idAttr.equals("String_Node_Str")) {
        Element secondElement=this.document.getDefaultRootElement().getElement(0);
        this.document.remove(secondElement.getStartOffset(),secondElement.getEndOffset() - secondElement.getStartOffset());
      }
    }
 catch (    BadLocationException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void ensureDocumentSize(){
  if (document.getLength() > Constants.CHAT_BUFFER_SIZE && document.getDefaultRootElement().getElementCount() > 2) {
    Element firstElement=this.document.getDefaultRootElement().getElement(0);
    try {
      if (firstElement != null)       this.document.remove(firstElement.getStartOffset(),firstElement.getEndOffset() - firstElement.getStartOffset());
      String idAttr=(String)firstElement.getAttributes().getAttribute("String_Node_Str");
      if (idAttr != null && idAttr.equals("String_Node_Str")) {
        Element secondElement=this.document.getDefaultRootElement().getElement(0);
        this.document.remove(secondElement.getStartOffset(),secondElement.getEndOffset() - secondElement.getStartOffset());
      }
    }
 catch (    BadLocationException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
}
Program: 104399
Project: 104399
Buggy source:
/** 
 * Get the PresenceStatus for a particular contact.
 * @param contactIdentifier the identifier of the contact whose statuswe're interested in.
 * @return PresenceStatus the <tt>PresenceStatus</tt> of the specified<tt>contact</tt>
 * @throws IllegalArgumentException if <tt>contact</tt> is not a contactknown to the underlying protocol provider
 * @throws IllegalStateException if the underlying protocol provider isnot registered/signed on a public service.
 * @throws OperationFailedException with code NETWORK_FAILURE ifretrieving the status fails due to errors experienced during network communication
 */
public PresenceStatus queryContactStatus(String contactIdentifier) throws IllegalArgumentException, IllegalStateException, OperationFailedException {
  return resolveContactID(contactIdentifier).getPresenceStatus();
}

Fixed version (ground truth):
/** 
 * Get the PresenceStatus for a particular contact.
 * @param contactIdentifier the identifier of the contact whose statuswe're interested in.
 * @return PresenceStatus the <tt>PresenceStatus</tt> of the specified<tt>contact</tt>
 * @throws IllegalArgumentException if <tt>contact</tt> is not a contactknown to the underlying protocol provider
 * @throws IllegalStateException if the underlying protocol provider isnot registered/signed on a public service.
 * @throws OperationFailedException with code NETWORK_FAILURE ifretrieving the status fails due to errors experienced during network communication
 */
public PresenceStatus queryContactStatus(String contactIdentifier) throws IllegalArgumentException, IllegalStateException, OperationFailedException {
  Contact contact=resolveContactID(contactIdentifier);
  if (contact == null) {
    throw new IllegalArgumentException("String_Node_Str" + contactIdentifier + "String_Node_Str");
  }
  return contact.getPresenceStatus();
}
Program: 104403
Project: 104403
Buggy source:
public void run(){
  for (byte i=0; i < 10; i++) {
synchronized (waitedCallIds) {
      if (waitedCallIds.size() == 0) {
        break;
      }
    }
synchronized (this) {
      try {
        wait(500);
      }
 catch (      InterruptedException e) {
        logger.debug("String_Node_Str" + "String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Check if we can't subscribe to this contact now
 */
public void run(){
  Iterator groupsIter=getServerStoredContactListRoot().subgroups();
  while (groupsIter.hasNext()) {
    ContactGroupSipImpl group=(ContactGroupSipImpl)groupsIter.next();
    Iterator contactsIter=group.contacts();
    while (contactsIter.hasNext()) {
      ContactSipImpl contact=(ContactSipImpl)contactsIter.next();
      forcePollContact(contact);
    }
  }
}
Program: 104407
Project: 104407
Buggy source:
/** 
 * Notifies all registered listeners of the new event.
 * @param oldValue the presence status we were in before the change.
 */
public void fireProviderMsgStatusChangeEvent(String oldValue){
  PropertyChangeEvent evt=new PropertyChangeEvent(this.parentProvider,ProviderPresenceStatusListener.STATUS_MESSAGE,oldValue,this.statusMessage);
  logger.debug("String_Node_Str" + this.providerPresenceStatusListeners.size() + "String_Node_Str"+ evt);
  Iterator listeners=null;
synchronized (this.providerPresenceStatusListeners) {
    listeners=new ArrayList(this.providerPresenceStatusListeners).iterator();
  }
  while (listeners.hasNext()) {
    ProviderPresenceStatusListener listener=(ProviderPresenceStatusListener)listeners.next();
    listener.providerStatusMessageChanged(evt);
  }
}

Fixed version (ground truth):
/** 
 * Notifies all registered listeners of the new event.
 * @param oldValue the presence status we were in before the change.
 */
public void fireProviderMsgStatusChangeEvent(String oldValue){
  PropertyChangeEvent evt=new PropertyChangeEvent(this.parentProvider,ProviderPresenceStatusListener.STATUS_MESSAGE,oldValue,this.statusMessage);
  logger.debug("String_Node_Str" + this.providerPresenceStatusListeners.size() + "String_Node_Str"+ evt);
  Iterator listeners=null;
synchronized (this.providerPresenceStatusListeners) {
    listeners=new ArrayList(this.providerPresenceStatusListeners).iterator();
  }
  while (listeners.hasNext()) {
    ProviderPresenceStatusListener listener=(ProviderPresenceStatusListener)listeners.next();
    listener.providerStatusMessageChanged(evt);
  }
  logger.debug("String_Node_Str");
}
Program: 104413
Project: 104413
Buggy source:
/** 
 * Secured call to XMLUtils.getText (no null returned but an empty string)
 * @param node the node with which call <tt>XMLUtils.getText()</tt>
 * @return the string contained in the node or an empty string if there isno text information in the node.
 */
private String getTextContent(Element node){
  String res=XMLUtils.getText(node);
  if (res == null) {
    return "String_Node_Str";
  }
  return res;
}

Fixed version (ground truth):
/** 
 * Secured call to XMLUtils.getText (no null returned but an empty string)
 * @param node the node with which call <tt>XMLUtils.getText()</tt>
 * @return the string contained in the node or an empty string if there isno text information in the node.
 */
private String getTextContent(Element node){
  String res=XMLUtils.getText(node);
  if (res == null) {
    logger.warn("String_Node_Str" + node.getNodeName() + "String_Node_Str");
    return "String_Node_Str";
  }
  return res;
}
Program: 104414
Project: 104414
Buggy source:
/** 
 * Formats message new lines.
 * @param message The source message string.
 * @return The message string with properly formatted new lines.
 */
private String processNewLines(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType != null && contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  return message.replaceAll("String_Node_Str",endPlainTextTag + "String_Node_Str" + startPlainTextTag);
}

Fixed version (ground truth):
/** 
 * Formats message new lines.
 * @param message The source message string.
 * @return The message string with properly formatted new lines.
 */
private String processNewLines(String message,String contentType){
  String startPlainTextTag="String_Node_Str";
  String endPlainTextTag="String_Node_Str";
  return message.replaceAll("String_Node_Str",endPlainTextTag + "String_Node_Str" + startPlainTextTag);
}
Program: 104415
Project: 104415
Buggy source:
/** 
 * Formats message smilies.
 * @param message The source message string.
 * @return The message string with properly formated smilies.
 */
private String processSmilies(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType != null && contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  ArrayList smiliesList=ImageLoader.getDefaultSmiliesPack();
  String regexp="String_Node_Str";
  for (int i=0; i < smiliesList.size(); i++) {
    Smiley smiley=(Smiley)smiliesList.get(i);
    String[] smileyStrings=smiley.getSmileyStrings();
    for (int j=0; j < smileyStrings.length; j++) {
      regexp+=GuiUtils.replaceSpecialRegExpChars(smileyStrings[j]) + "String_Node_Str";
    }
  }
  regexp=regexp.substring(0,regexp.length() - 1);
  Pattern p=Pattern.compile(regexp);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement=endPlainTextTag + "String_Node_Str" + ImageLoader.getSmiley(matchGroup).getImagePath()+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    m.appendReplacement(msgBuffer,GuiUtils.replaceSpecialRegExpChars(replacement));
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}

Fixed version (ground truth):
/** 
 * Formats message smilies.
 * @param message The source message string.
 * @return The message string with properly formated smilies.
 */
private String processSmilies(String message,String contentType){
  String startPlainTextTag="String_Node_Str";
  String endPlainTextTag="String_Node_Str";
  ArrayList smiliesList=ImageLoader.getDefaultSmiliesPack();
  String regexp="String_Node_Str";
  for (int i=0; i < smiliesList.size(); i++) {
    Smiley smiley=(Smiley)smiliesList.get(i);
    String[] smileyStrings=smiley.getSmileyStrings();
    for (int j=0; j < smileyStrings.length; j++) {
      regexp+=GuiUtils.replaceSpecialRegExpChars(smileyStrings[j]) + "String_Node_Str";
    }
  }
  regexp=regexp.substring(0,regexp.length() - 1);
  Pattern p=Pattern.compile(regexp);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement=endPlainTextTag + "String_Node_Str" + ImageLoader.getSmiley(matchGroup).getImagePath()+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    m.appendReplacement(msgBuffer,GuiUtils.replaceSpecialRegExpChars(replacement));
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}
Program: 104416
Project: 104416
Buggy source:
/** 
 * Formats the given message. Processes all smilies chars, new lines and all the links.
 * @return the formatted message
 */
private String formatMessage(String message,String contentType){
  String linkProcessedString=processLinks(message,contentType);
  String newLinesProcessedString=processNewLines(linkProcessedString,contentType);
  return processSmilies(newLinesProcessedString,contentType);
}

Fixed version (ground truth):
/** 
 * Formats the given message. Processes all smilies chars, new lines and all the links.
 * @return the formatted message
 */
private String formatMessage(String message,String contentType){
  String processedString=message;
  if (contentType == null || !contentType.equals(HTML_CONTENT_TYPE)) {
    String linkProcessedString=processLinks(message,contentType);
    processedString=processNewLines(linkProcessedString,contentType);
  }
  return processSmilies(processedString,contentType);
}
Program: 104417
Project: 104417
Buggy source:
/** 
 * Formats all links in the given message.
 * @param message The source message string.
 * @return The message string with properly formatted links.
 */
private String processLinks(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType != null && contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  String wwwURL="String_Node_Str";
  String protocolURL="String_Node_Str";
  String url="String_Node_Str" + wwwURL + "String_Node_Str"+ protocolURL+ "String_Node_Str";
  Pattern p=Pattern.compile(url);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement;
    if (matchGroup.startsWith("String_Node_Str")) {
      replacement=endPlainTextTag + "String_Node_Str" + "String_Node_Str"+ matchGroup+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    }
 else {
      replacement=endPlainTextTag + "String_Node_Str" + matchGroup+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    }
    m.appendReplacement(msgBuffer,replacement);
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}

Fixed version (ground truth):
/** 
 * Formats all links in the given message.
 * @param message The source message string.
 * @return The message string with properly formatted links.
 */
private String processLinks(String message,String contentType){
  String startPlainTextTag="String_Node_Str";
  String endPlainTextTag="String_Node_Str";
  String wwwURL="String_Node_Str";
  String protocolURL="String_Node_Str";
  String url="String_Node_Str" + wwwURL + "String_Node_Str"+ protocolURL+ "String_Node_Str";
  Pattern p=Pattern.compile(url);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement;
    if (matchGroup.startsWith("String_Node_Str")) {
      replacement=endPlainTextTag + "String_Node_Str" + "String_Node_Str"+ matchGroup+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    }
 else {
      replacement=endPlainTextTag + "String_Node_Str" + matchGroup+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    }
    m.appendReplacement(msgBuffer,replacement);
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}
Program: 104418
Project: 104418
Buggy source:
/** 
 * Register a service. The service is registered for access by other jmdns clients. The name of the service may be changed to make it unique.
 * @param info of service
 * @throws java.io.IOException
 */
public void registerService(ServiceInfo info) throws IOException {
  registerServiceType(info.type);
  info.server=localHost.getName();
  info.addr=localHost.getAddress();
synchronized (this) {
    makeServiceNameUnique(info);
    services.put(info.getQualifiedName().toLowerCase(),info);
  }
  new Prober().start();
  try {
synchronized (info) {
      while (info.getState().compareTo(DNSState.ANNOUNCED) < 0) {
        info.wait();
      }
    }
  }
 catch (  InterruptedException e) {
  }
  logger.fine("String_Node_Str" + info);
}

Fixed version (ground truth):
/** 
 * Register a service. The service is registered for access by other jmdns clients. The name of the service may be changed to make it unique.
 * @param info of service
 * @throws java.io.IOException
 */
public void registerService(ServiceInfo info) throws IOException {
  registerServiceType(info.type);
  info.server=localHost.getName();
  info.addr=localHost.getAddress();
synchronized (this) {
    makeServiceNameUnique(info);
    services.put(info.getQualifiedName().toLowerCase(),info);
  }
  new Prober().start();
  try {
synchronized (info) {
      while (info.getState().compareTo(DNSState.ANNOUNCED) < 0) {
        info.wait();
      }
    }
  }
 catch (  InterruptedException e) {
    logger.error(e.getMessage(),e);
  }
  logger.debug("String_Node_Str" + info);
}
Program: 104419
Project: 104419
Buggy source:
public void run(){
  try {
    if (++count < 3) {
      logger.debug("String_Node_Str");
      DNSOutgoing out=new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA);
      for (int i=0; i < infos.length; i++) {
        ServiceInfo info=infos[i];
        out.addAnswer(new DNSRecord.Pointer(info.type,DNSConstants.TYPE_PTR,DNSConstants.CLASS_IN,ttl,info.getQualifiedName()),0);
        out.addAnswer(new DNSRecord.Service(info.getQualifiedName(),DNSConstants.TYPE_SRV,DNSConstants.CLASS_IN,ttl,info.priority,info.weight,info.port,localHost.getName()),0);
        out.addAnswer(new DNSRecord.Text(info.getQualifiedName(),DNSConstants.TYPE_TXT,DNSConstants.CLASS_IN,ttl,info.text),0);
        DNSRecord answer=localHost.getDNS4AddressRecord();
        if (answer != null) {
          out.addAnswer(answer,0);
        }
        answer=localHost.getDNS6AddressRecord();
        if (answer != null) {
          out.addAnswer(answer,0);
        }
      }
      send(out);
    }
 else {
synchronized (lock) {
        closed=true;
        lock.notifyAll();
      }
      this.cancel();
    }
  }
 catch (  Throwable e) {
    logger.log(Level.WARNING,"String_Node_Str",e);
    recover();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    if (++count < 3) {
      logger.debug("String_Node_Str");
      DNSOutgoing out=new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA);
      for (int i=0; i < infos.length; i++) {
        ServiceInfo info=infos[i];
        out.addAnswer(new DNSRecord.Pointer(info.type,DNSConstants.TYPE_PTR,DNSConstants.CLASS_IN,ttl,info.getQualifiedName()),0);
        out.addAnswer(new DNSRecord.Service(info.getQualifiedName(),DNSConstants.TYPE_SRV,DNSConstants.CLASS_IN,ttl,info.priority,info.weight,info.port,localHost.getName()),0);
        out.addAnswer(new DNSRecord.Text(info.getQualifiedName(),DNSConstants.TYPE_TXT,DNSConstants.CLASS_IN,ttl,info.text),0);
        DNSRecord answer=localHost.getDNS4AddressRecord();
        if (answer != null) {
          out.addAnswer(answer,0);
        }
        answer=localHost.getDNS6AddressRecord();
        if (answer != null) {
          out.addAnswer(answer,0);
        }
      }
      send(out);
    }
 else {
synchronized (lock) {
        closed=true;
        lock.notifyAll();
      }
      this.cancel();
    }
  }
 catch (  Throwable e) {
    logger.warn("String_Node_Str",e);
    recover();
  }
}
Program: 104421
Project: 104421
Buggy source:
/** 
 * Send an outgoing multicast DNS message.
 */
private void send(DNSOutgoing out) throws IOException {
  out.finish();
  if (!out.isEmpty()) {
    DatagramPacket packet=new DatagramPacket(out.data,out.off,group,DNSConstants.MDNS_PORT);
    try {
      DNSIncoming msg=new DNSIncoming(packet);
      logger.finest("String_Node_Str" + msg.print(true));
    }
 catch (    IOException e) {
      logger.throwing(getClass().toString(),"String_Node_Str",e);
    }
    socket.send(packet);
  }
}

Fixed version (ground truth):
/** 
 * Send an outgoing multicast DNS message.
 */
private void send(DNSOutgoing out) throws IOException {
  out.finish();
  if (!out.isEmpty()) {
    DatagramPacket packet=new DatagramPacket(out.data,out.off,group,DNSConstants.MDNS_PORT);
    try {
      DNSIncoming msg=new DNSIncoming(packet);
      logger.trace("String_Node_Str" + msg.print(true));
    }
 catch (    IOException exc) {
      logger.error("String_Node_Str",exc);
    }
    socket.send(packet);
  }
}
Program: 104422
Project: 104422
Buggy source:
private void closeMulticastSocket(){
  logger.debug("String_Node_Str");
  if (socket != null) {
    try {
      socket.leaveGroup(group);
      socket.close();
      if (incomingListener != null) {
        incomingListener.join();
      }
    }
 catch (    Exception exception) {
      logger.log(Level.WARNING,"String_Node_Str",exception);
    }
    socket=null;
  }
}

Fixed version (ground truth):
private void closeMulticastSocket(){
  logger.debug("String_Node_Str");
  if (socket != null) {
    try {
      socket.leaveGroup(group);
      socket.close();
      if (incomingListener != null) {
        incomingListener.join();
      }
    }
 catch (    Exception exception) {
      logger.warn("String_Node_Str",exception);
    }
    socket=null;
  }
}
Program: 104423
Project: 104423
Buggy source:
/** 
 * Recover jmdns when there is an error.
 */
protected void recover(){
  logger.debug("String_Node_Str");
  if (DNSState.CANCELED != state) {
synchronized (this) {
      logger.debug("String_Node_Str");
      state=DNSState.CANCELED;
      Collection oldServiceInfos=new ArrayList(services.values());
      unregisterAllServices();
      disposeServiceCollectors();
      closeMulticastSocket();
      cache.clear();
      logger.debug("String_Node_Str");
      try {
        openMulticastSocket(localHost);
        start(oldServiceInfos);
      }
 catch (      Exception exception) {
        logger.log(Level.WARNING,"String_Node_Str",exception);
      }
      logger.log(Level.WARNING,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Recover jmdns when there is an error.
 */
protected void recover(){
  logger.debug("String_Node_Str");
  if (DNSState.CANCELED != state) {
synchronized (this) {
      logger.debug("String_Node_Str");
      state=DNSState.CANCELED;
      Collection oldServiceInfos=new ArrayList(services.values());
      unregisterAllServices();
      disposeServiceCollectors();
      closeMulticastSocket();
      cache.clear();
      logger.debug("String_Node_Str");
      try {
        openMulticastSocket(localHost);
        start(oldServiceInfos);
      }
 catch (      Exception exception) {
        logger.warn("String_Node_Str",exception);
      }
      logger.warn("String_Node_Str");
    }
  }
}
Program: 104424
Project: 104424
Buggy source:
public ServiceCollector(String type){
  String SLevel=System.getProperty("String_Node_Str");
  if (SLevel == null)   SLevel="String_Node_Str";
  logger.setLevel(Level.parse(SLevel));
  this.type=type;
}

Fixed version (ground truth):
public ServiceCollector(String type){
  this.type=type;
}
Program: 104426
Project: 104426
Buggy source:
/** 
 * Processes the message given by the parameters.
 * @param contact the message source or destination contact
 * @param timestamp the timestamp of the message
 * @param messageType INCOMING or OUTGOING
 * @param messageContent the content text of the message
 */
private void processMessage(Contact contact,Date timestamp,String messageType,String messageContent){
  Contact containedContact=metaContact.getContact(contact.getAddress(),contact.getProtocolProvider());
  if (containedContact != null) {
    int lastDateIndex=datesPanel.getDatesNumber() - 1;
    if (lastDateIndex < 0)     return;
    Date lastDate=datesPanel.getDate(lastDateIndex);
    if (lastDate != null && GuiUtils.compareDates(lastDate,timestamp) == 0) {
      HTMLDocument document=(HTMLDocument)dateHistoryTable.get(lastDate);
      if (document != null) {
        String processedMessage=chatConvPanel.processMessage(contact.getDisplayName(),timestamp,messageType,messageContent,searchKeyword);
        this.appendMessageToDocument(document,processedMessage);
      }
    }
 else     if (lastDate == null || GuiUtils.compareDates(lastDate,timestamp) < 0) {
      long milisecondsPerDay=24 * 60 * 60* 1000;
      Date date=new Date(timestamp.getTime() - timestamp.getTime() % milisecondsPerDay);
      datesVector.add(date);
      datesPanel.addDate(date);
    }
  }
}

Fixed version (ground truth):
/** 
 * Processes the message given by the parameters.
 * @param contact the message source or destination contact
 * @param timestamp the timestamp of the message
 * @param messageType INCOMING or OUTGOING
 * @param messageContent the content text of the message
 */
private void processMessage(Contact contact,Date timestamp,String messageType,String messageContent,String messageContentType){
  Contact containedContact=metaContact.getContact(contact.getAddress(),contact.getProtocolProvider());
  if (containedContact != null) {
    int lastDateIndex=datesPanel.getDatesNumber() - 1;
    if (lastDateIndex < 0)     return;
    Date lastDate=datesPanel.getDate(lastDateIndex);
    if (lastDate != null && GuiUtils.compareDates(lastDate,timestamp) == 0) {
      HTMLDocument document=(HTMLDocument)dateHistoryTable.get(lastDate);
      if (document != null) {
        String processedMessage=chatConvPanel.processMessage(contact.getDisplayName(),timestamp,messageType,messageContent,messageContentType,searchKeyword);
        this.appendMessageToDocument(document,processedMessage);
      }
    }
 else     if (lastDate == null || GuiUtils.compareDates(lastDate,timestamp) < 0) {
      long milisecondsPerDay=24 * 60 * 60* 1000;
      Date date=new Date(timestamp.getTime() - timestamp.getTime() % milisecondsPerDay);
      datesVector.add(date);
      datesPanel.addDate(date);
    }
  }
}
Program: 104427
Project: 104427
Buggy source:
/** 
 * Implements MessageListener.messageDelivered method in order to refresh the history when new message is sent.
 */
public void messageDelivered(MessageDeliveredEvent evt){
  Contact destContact=evt.getDestinationContact();
  this.processMessage(destContact,evt.getTimestamp(),Constants.OUTGOING_MESSAGE,evt.getSourceMessage().getContent());
}

Fixed version (ground truth):
/** 
 * Implements MessageListener.messageDelivered method in order to refresh the history when new message is sent.
 */
public void messageDelivered(MessageDeliveredEvent evt){
  Contact destContact=evt.getDestinationContact();
  this.processMessage(destContact,evt.getTimestamp(),Constants.OUTGOING_MESSAGE,evt.getSourceMessage().getContent(),evt.getSourceMessage().getContentType());
}
Program: 104428
Project: 104428
Buggy source:
/** 
 * Implements MessageListener.messageReceived method in order to refresh the history when new message is received.
 */
public void messageReceived(MessageReceivedEvent evt){
  Contact sourceContact=evt.getSourceContact();
  this.processMessage(sourceContact,evt.getTimestamp(),Constants.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
}

Fixed version (ground truth):
/** 
 * Implements MessageListener.messageReceived method in order to refresh the history when new message is received.
 */
public void messageReceived(MessageReceivedEvent evt){
  Contact sourceContact=evt.getSourceContact();
  this.processMessage(sourceContact,evt.getTimestamp(),Constants.INCOMING_MESSAGE,evt.getSourceMessage().getContent(),evt.getSourceMessage().getContentType());
}
Program: 104429
Project: 104429
Buggy source:
/** 
 * Shows the history given by the collection into a ChatConversationPanel.
 * @param historyRecords a collection of history records
 */
private HTMLDocument createHistory(Collection historyRecords){
  if (historyRecords.size() > 0) {
    Iterator i=historyRecords.iterator();
    String processedMessage="String_Node_Str";
    while (i.hasNext()) {
      Object o=i.next();
      if (o instanceof MessageDeliveredEvent) {
        MessageDeliveredEvent evt=(MessageDeliveredEvent)o;
        ProtocolProviderService protocolProvider=evt.getDestinationContact().getProtocolProvider();
        processedMessage=chatConvPanel.processMessage(this.mainFrame.getAccount(protocolProvider),evt.getTimestamp(),Constants.OUTGOING_MESSAGE,evt.getSourceMessage().getContent(),searchKeyword);
      }
 else       if (o instanceof MessageReceivedEvent) {
        MessageReceivedEvent evt=(MessageReceivedEvent)o;
        processedMessage=chatConvPanel.processMessage(evt.getSourceContact().getDisplayName(),evt.getTimestamp(),Constants.INCOMING_MESSAGE,evt.getSourceMessage().getContent(),searchKeyword);
      }
      chatConvPanel.appendMessageToEnd(processedMessage);
    }
  }
  this.chatConvPanel.setDefaultContent();
  return this.chatConvPanel.getContent();
}

Fixed version (ground truth):
/** 
 * Shows the history given by the collection into a ChatConversationPanel.
 * @param historyRecords a collection of history records
 */
private HTMLDocument createHistory(Collection historyRecords){
  if (historyRecords.size() > 0) {
    Iterator i=historyRecords.iterator();
    String processedMessage="String_Node_Str";
    while (i.hasNext()) {
      Object o=i.next();
      if (o instanceof MessageDeliveredEvent) {
        MessageDeliveredEvent evt=(MessageDeliveredEvent)o;
        ProtocolProviderService protocolProvider=evt.getDestinationContact().getProtocolProvider();
        processedMessage=chatConvPanel.processMessage(this.mainFrame.getAccount(protocolProvider),evt.getTimestamp(),Constants.OUTGOING_MESSAGE,evt.getSourceMessage().getContent(),evt.getSourceMessage().getContentType(),searchKeyword);
      }
 else       if (o instanceof MessageReceivedEvent) {
        MessageReceivedEvent evt=(MessageReceivedEvent)o;
        processedMessage=chatConvPanel.processMessage(evt.getSourceContact().getDisplayName(),evt.getTimestamp(),Constants.INCOMING_MESSAGE,evt.getSourceMessage().getContent(),evt.getSourceMessage().getContentType(),searchKeyword);
      }
      chatConvPanel.appendMessageToEnd(processedMessage);
    }
  }
  this.chatConvPanel.setDefaultContent();
  return this.chatConvPanel.getContent();
}
Program: 104430
Project: 104430
Buggy source:
/** 
 * Creates a <tt>MetaContactGroup</tt> with the specified group name. The meta contact group would only be created locally and resolved against the different server stored protocol contact lists upon the creation of the first protocol specific child contact in the respective group. * @param parentGroup the <tt>MetaContactGroup</tt> that should be the parent of the newly created group.
 * @param parent the meta contact group inside which the new child group must be created.
 * @param groupName the name of the <tt>MetaContactGroup</tt> to create.
 * @throws MetaContactListException with an appropriate code if the operation fails for some reason.
 */
public void createMetaContactGroup(MetaContactGroup parent,String groupName) throws MetaContactListException {
  if (!(parent instanceof MetaContactGroupImpl)) {
    throw new IllegalArgumentException(parent + "String_Node_Str");
  }
  MetaContactGroupImpl newMetaGroup=new MetaContactGroupImpl(groupName);
  ((MetaContactGroupImpl)parent).addSubgroup(newMetaGroup);
  fireMetaContactGroupEvent(newMetaGroup,null,null,MetaContactGroupEvent.META_CONTACT_GROUP_ADDED);
}

Fixed version (ground truth):
/** 
 * Creates a <tt>MetaContactGroup</tt> with the specified group name. The meta contact group would only be created locally and resolved against the different server stored protocol contact lists upon the creation of the first protocol specific child contact in the respective group. * @param parentGroup the <tt>MetaContactGroup</tt> that should be the parent of the newly created group.
 * @param parent the meta contact group inside which the new child group must be created.
 * @param groupName the name of the <tt>MetaContactGroup</tt> to create.
 * @throws MetaContactListException with an appropriate code if the operation fails for some reason.
 */
public void createMetaContactGroup(MetaContactGroup parent,String groupName) throws MetaContactListException {
  if (!(parent instanceof MetaContactGroupImpl)) {
    throw new IllegalArgumentException(parent + "String_Node_Str");
  }
  Iterator subgroups=parent.getSubgroups();
  while (subgroups.hasNext()) {
    MetaContactGroup group=(MetaContactGroup)subgroups.next();
    if (group.getGroupName().equals(groupName)) {
      throw new MetaContactListException("String_Node_Str" + parent.getGroupName() + "String_Node_Str"+ "String_Node_Str"+ groupName,new CloneNotSupportedException("String_Node_Str"),MetaContactListException.CODE_GROUP_ALREADY_EXISTS_ERROR);
    }
  }
  MetaContactGroupImpl newMetaGroup=new MetaContactGroupImpl(groupName);
  ((MetaContactGroupImpl)parent).addSubgroup(newMetaGroup);
  fireMetaContactGroupEvent(newMetaGroup,null,null,MetaContactGroupEvent.META_CONTACT_GROUP_ADDED);
}
Program: 104431
Project: 104431
Buggy source:
/** 
 * Retrns a Contact header containing our sip uri and therefore usable in all but REGISTER requests. Same as calling getContactHeader(false)
 * @return a Contact header containing our sip uri
 */
public ContactHeader getContactHeader(){
  if (this.genericContactHeader == null) {
    genericContactHeader=headerFactory.createContactHeader(ourSipAddress);
    try {
      genericContactHeader.getAddress().setDisplayName(getOurDisplayName());
    }
 catch (    ParseException ex) {
      logger.error("String_Node_Str",ex);
    }
    logger.debug("String_Node_Str" + genericContactHeader);
  }
  return genericContactHeader;
}

Fixed version (ground truth):
/** 
 * Retrns a Contact header containing a sip URI base on a localhost address and thereforeusable in REGISTER requests only.
 * @param targetAddress the address of the registrar that this contactheader is meant for.
 * @param srcListeningPoint the listening point that will be used whenaccessing the registrar.
 * @return a Contact header based upon a local inet address.
 * @throws OperationFailedException if we fail constructing the contactheader.
 */
ContactHeader getContactHeader(InetAddress targetAddress,ListeningPoint srcListeningPoint) throws OperationFailedException {
  ContactHeader registrationContactHeader=null;
  try {
    InetSocketAddress localAddress=SipActivator.getNetworkAddressManagerService().getPublicAddressFor(targetAddress,srcListeningPoint.getPort());
    SipURI contactURI=addressFactory.createSipURI(((SipURI)ourSipAddress.getURI()).getUser(),localAddress.getAddress().getHostAddress());
    contactURI.setTransportParam(srcListeningPoint.getTransport());
    contactURI.setPort(localAddress.getPort());
    Address contactAddress=addressFactory.createAddress(contactURI);
    if (ourDisplayName != null) {
      contactAddress.setDisplayName(ourDisplayName);
    }
    registrationContactHeader=headerFactory.createContactHeader(contactAddress);
    logger.debug("String_Node_Str" + registrationContactHeader);
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex);
  }
  return registrationContactHeader;
}
Program: 104432
Project: 104432
Buggy source:
/** 
 * Returns the listening point that should be used for communiction with our current registrar.
 * @return the listening point that should be used for communiction with ourcurrent registrar.
 */
private ListeningPoint getRegistrarListeningPoint(){
  return sipProvider.getListeningPoint(registrarURI.getTransportParam());
}

Fixed version (ground truth):
/** 
 * Returns the listening point that should be used for communiction with our current registrar.
 * @return the listening point that should be used for communiction with ourcurrent registrar.
 */
ListeningPoint getRegistrarListeningPoint(){
  return sipProvider.getListeningPoint(registrarURI.getTransportParam());
}
Program: 104434
Project: 104434
Buggy source:
/** 
 * Formats message new lines.
 * @param message The source message string.
 * @return The message string with properly formatted new lines.
 */
private String processNewLines(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  return message.replaceAll("String_Node_Str",endPlainTextTag + "String_Node_Str" + startPlainTextTag);
}

Fixed version (ground truth):
/** 
 * Formats message new lines.
 * @param message The source message string.
 * @return The message string with properly formatted new lines.
 */
private String processNewLines(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType != null && contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  return message.replaceAll("String_Node_Str",endPlainTextTag + "String_Node_Str" + startPlainTextTag);
}
Program: 104435
Project: 104435
Buggy source:
/** 
 * Formats message smilies.
 * @param message The source message string.
 * @return The message string with properly formated smilies.
 */
private String processSmilies(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  ArrayList smiliesList=ImageLoader.getDefaultSmiliesPack();
  String regexp="String_Node_Str";
  for (int i=0; i < smiliesList.size(); i++) {
    Smiley smiley=(Smiley)smiliesList.get(i);
    String[] smileyStrings=smiley.getSmileyStrings();
    for (int j=0; j < smileyStrings.length; j++) {
      regexp+=GuiUtils.replaceSpecialRegExpChars(smileyStrings[j]) + "String_Node_Str";
    }
  }
  regexp=regexp.substring(0,regexp.length() - 1);
  Pattern p=Pattern.compile(regexp);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement=endPlainTextTag + "String_Node_Str" + ImageLoader.getSmiley(matchGroup).getImagePath()+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    m.appendReplacement(msgBuffer,GuiUtils.replaceSpecialRegExpChars(replacement));
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}

Fixed version (ground truth):
/** 
 * Formats message smilies.
 * @param message The source message string.
 * @return The message string with properly formated smilies.
 */
private String processSmilies(String message,String contentType){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType != null && contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  ArrayList smiliesList=ImageLoader.getDefaultSmiliesPack();
  String regexp="String_Node_Str";
  for (int i=0; i < smiliesList.size(); i++) {
    Smiley smiley=(Smiley)smiliesList.get(i);
    String[] smileyStrings=smiley.getSmileyStrings();
    for (int j=0; j < smileyStrings.length; j++) {
      regexp+=GuiUtils.replaceSpecialRegExpChars(smileyStrings[j]) + "String_Node_Str";
    }
  }
  regexp=regexp.substring(0,regexp.length() - 1);
  Pattern p=Pattern.compile(regexp);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement=endPlainTextTag + "String_Node_Str" + ImageLoader.getSmiley(matchGroup).getImagePath()+ "String_Node_Str"+ matchGroup+ "String_Node_Str"+ startPlainTextTag;
    m.appendReplacement(msgBuffer,GuiUtils.replaceSpecialRegExpChars(replacement));
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}
Program: 104436
Project: 104436
Buggy source:
/** 
 * Highlights keywords searched in the history.
 * @param message the source message
 * @param keyword the searched keyword
 * @return the formatted message
 */
private String processKeyword(String message,String contentType,String keyword){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  Pattern p=Pattern.compile(keyword,Pattern.CASE_INSENSITIVE);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement=endPlainTextTag + "String_Node_Str" + matchGroup+ "String_Node_Str"+ startPlainTextTag;
    m.appendReplacement(msgBuffer,GuiUtils.replaceSpecialRegExpChars(replacement));
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}

Fixed version (ground truth):
/** 
 * Highlights keywords searched in the history.
 * @param message the source message
 * @param keyword the searched keyword
 * @return the formatted message
 */
private String processKeyword(String message,String contentType,String keyword){
  String startPlainTextTag;
  String endPlainTextTag;
  if (contentType != null && contentType.equals(HTML_CONTENT_TYPE)) {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
 else {
    startPlainTextTag="String_Node_Str";
    endPlainTextTag="String_Node_Str";
  }
  Pattern p=Pattern.compile(keyword,Pattern.CASE_INSENSITIVE);
  Matcher m=p.matcher(message);
  StringBuffer msgBuffer=new StringBuffer();
  boolean matchSuccessfull=false;
  while (m.find()) {
    if (!matchSuccessfull)     matchSuccessfull=true;
    String matchGroup=m.group().trim();
    String replacement=endPlainTextTag + "String_Node_Str" + matchGroup+ "String_Node_Str"+ startPlainTextTag;
    m.appendReplacement(msgBuffer,GuiUtils.replaceSpecialRegExpChars(replacement));
  }
  m.appendTail(msgBuffer);
  return msgBuffer.toString();
}