Program: 104159
Project: 104159
Buggy source:
/** 
 * Sends the <tt>message</tt> to the destination indicated by the <tt>to</tt> contact.
 * @param to the <tt>Contact</tt> to send <tt>message</tt> to
 * @param message the <tt>Message</tt> to send.
 * @throws java.lang.IllegalStateException if the underlying stack isnot registered and initialized.
 * @throws java.lang.IllegalArgumentException if <tt>to</tt> is not aninstance of ContactImpl.
 */
public void sendInstantMessage(Contact to,Message message) throws IllegalStateException, IllegalArgumentException {
  assertConnected();
  if (!(to instanceof ContactYahooImpl))   throw new IllegalArgumentException("String_Node_Str" + to);
  try {
    String toUserID=((ContactYahooImpl)to).getID();
    byte[] msgBytesToBeSent=message.getContent().getBytes();
    do {
      if (msgBytesToBeSent.length > MAX_MESSAGE_LENGTH) {
        byte[] tmp1=new byte[MAX_MESSAGE_LENGTH];
        System.arraycopy(msgBytesToBeSent,0,tmp1,0,MAX_MESSAGE_LENGTH);
        byte[] tmp2=new byte[msgBytesToBeSent.length - MAX_MESSAGE_LENGTH];
        System.arraycopy(msgBytesToBeSent,MAX_MESSAGE_LENGTH,tmp2,0,tmp2.length);
        msgBytesToBeSent=tmp2;
        yahooProvider.getYahooSession().sendMessage(toUserID,new String(tmp1));
      }
 else {
        yahooProvider.getYahooSession().sendMessage(toUserID,new String(msgBytesToBeSent));
      }
      MessageDeliveredEvent msgDeliveredEvt=new MessageDeliveredEvent(message,to,new Date());
      fireMessageEvent(msgDeliveredEvt);
    }
 while (msgBytesToBeSent.length > MAX_MESSAGE_LENGTH);
  }
 catch (  IOException ex) {
    logger.fatal("String_Node_Str" + ex.getMessage());
    MessageDeliveryFailedEvent evt=new MessageDeliveryFailedEvent(message,to,MessageDeliveryFailedEvent.NETWORK_FAILURE,new Date());
    fireMessageEvent(evt);
    return;
  }
}

Fixed version (ground truth):
/** 
 * Sends the <tt>message</tt> to the destination indicated by the <tt>to</tt> contact.
 * @param to the <tt>Contact</tt> to send <tt>message</tt> to
 * @param message the <tt>Message</tt> to send.
 * @throws java.lang.IllegalStateException if the underlying stack isnot registered and initialized.
 * @throws java.lang.IllegalArgumentException if <tt>to</tt> is not aninstance of ContactImpl.
 */
public void sendInstantMessage(Contact to,Message message) throws IllegalStateException, IllegalArgumentException {
  assertConnected();
  if (!(to instanceof ContactYahooImpl))   throw new IllegalArgumentException("String_Node_Str" + to);
  try {
    String toUserID=((ContactYahooImpl)to).getID();
    byte[] msgBytesToBeSent=message.getContent().trim().getBytes();
    do {
      if (msgBytesToBeSent.length > MAX_MESSAGE_LENGTH) {
        byte[] tmp1=new byte[MAX_MESSAGE_LENGTH];
        System.arraycopy(msgBytesToBeSent,0,tmp1,0,MAX_MESSAGE_LENGTH);
        byte[] tmp2=new byte[msgBytesToBeSent.length - MAX_MESSAGE_LENGTH];
        System.arraycopy(msgBytesToBeSent,MAX_MESSAGE_LENGTH,tmp2,0,tmp2.length);
        msgBytesToBeSent=tmp2;
        yahooProvider.getYahooSession().sendMessage(toUserID,new String(tmp1));
      }
 else {
        yahooProvider.getYahooSession().sendMessage(toUserID,new String(msgBytesToBeSent));
      }
      MessageDeliveredEvent msgDeliveredEvt=new MessageDeliveredEvent(message,to,new Date());
      fireMessageEvent(msgDeliveredEvt);
    }
 while (msgBytesToBeSent.length > MAX_MESSAGE_LENGTH);
  }
 catch (  IOException ex) {
    logger.fatal("String_Node_Str" + ex.getMessage());
    MessageDeliveryFailedEvent evt=new MessageDeliveryFailedEvent(message,to,MessageDeliveryFailedEvent.NETWORK_FAILURE,new Date());
    fireMessageEvent(evt);
    return;
  }
}