Program: 134860
Project: 134860
Buggy source:
/** 
 * Attempts to send <code>logRecords</code> over to the remote logging service. To not lose any log records in case of failure, they can be obtained from the returned  <code>FailedLogRecords</code> object, and should be fed back to the log record queue in order to try again later. <p> Should not be called concurrently (which can't happen since we use a single threaded executor  in <code>DispatchingLogQueue</code>). <p> Sorts all log records by timestamp before converting them for remote transmission.
 * @param logRecords
 * @return those LogRecords that failed to be sent, either because they could not be converted to Any, or because the remote logger failed.
 */
FailedLogRecords sendLogRecords(LogRecord[] logRecords){
  Arrays.sort(logRecords,timestampLogRecordComparator);
  FailedLogRecords failures=new FailedLogRecords();
  List<LogRecord> candidateLogRecords=new ArrayList<LogRecord>();
  if (useAcsLogServiceExtensions) {
    List<XmlLogRecord> remoteLogRecords=new ArrayList<XmlLogRecord>();
    for (int i=0; i < logRecords.length; i++) {
      if (i < getBufferSize()) {
        try {
          String xml=((AcsXMLLogFormatter)logFormatter).format(logRecords[i]);
          int level=AcsLogLevel.getNativeLevel(logRecords[i].getLevel()).getAcsLevel().value;
          XmlLogRecord remoteLogRecord=new XmlLogRecord(xml,(short)level);
          remoteLogRecords.add(remoteLogRecord);
          candidateLogRecords.add(logRecords[i]);
        }
 catch (        RuntimeException e) {
          failures.addSerializationFailure(logRecords[i]);
        }
      }
 else {
        failures.addSendFailure(logRecords[i]);
      }
      if (!remoteLogRecords.isEmpty()) {
        XmlLogRecord[] remoteLogRecordsArray=remoteLogRecords.toArray(new XmlLogRecord[remoteLogRecords.size()]);
        writeRecords(remoteLogRecordsArray);
      }
    }
  }
 else {
    List<Any> anyLogRecords=new ArrayList<Any>();
    for (int i=0; i < logRecords.length; i++) {
      if (i < getBufferSize()) {
        try {
          Any anyLogRecord=orb.create_any();
          anyLogRecord=logFormatter.formatAny(anyLogRecord,logRecords[i]);
          anyLogRecords.add(anyLogRecord);
          candidateLogRecords.add(logRecords[i]);
        }
 catch (        RuntimeException e) {
          failures.addSerializationFailure(logRecords[i]);
        }
      }
 else {
        failures.addSendFailure(logRecords[i]);
      }
    }
    if (!anyLogRecords.isEmpty()) {
      Any[] anyLogRecordsArray=anyLogRecords.toArray(new Any[anyLogRecords.size()]);
      try {
        writeRecords(anyLogRecordsArray);
      }
 catch (      Throwable thr) {
        failures.addSendFailures(candidateLogRecords);
      }
    }
  }
  return failures;
}

Fixed version (ground truth):
/** 
 * Attempts to send <code>logRecords</code> over to the remote logging service. To not lose any log records in case of failure, they can be obtained from the returned  <code>FailedLogRecords</code> object, and should be fed back to the log record queue in order to try again later. <p> Should not be called concurrently (which can't happen since we use a single threaded executor  in <code>DispatchingLogQueue</code>). <p> Sorts all log records by timestamp before converting them for remote transmission.
 * @param logRecords
 * @return those LogRecords that failed to be sent, either because they could not be converted to Any, or because the remote logger failed.
 */
FailedLogRecords sendLogRecords(LogRecord[] logRecords){
  Arrays.sort(logRecords,timestampLogRecordComparator);
  FailedLogRecords failures=new FailedLogRecords();
  List<LogRecord> candidateLogRecords=new ArrayList<LogRecord>();
  if (useAcsLogServiceExtensions) {
    List<XmlLogRecord> remoteLogRecords=new ArrayList<XmlLogRecord>();
    for (int i=0; i < logRecords.length; i++) {
      if (i < getBufferSize()) {
        try {
          String xml=((AcsXMLLogFormatter)logFormatter).format(logRecords[i]);
          int level=AcsLogLevel.getNativeLevel(logRecords[i].getLevel()).getAcsLevel().value;
          XmlLogRecord remoteLogRecord=new XmlLogRecord(xml,(short)level);
          remoteLogRecords.add(remoteLogRecord);
          candidateLogRecords.add(logRecords[i]);
        }
 catch (        RuntimeException e) {
          failures.addSerializationFailure(logRecords[i]);
        }
      }
 else {
        failures.addSendFailure(logRecords[i]);
      }
    }
    if (!remoteLogRecords.isEmpty()) {
      XmlLogRecord[] remoteLogRecordsArray=remoteLogRecords.toArray(new XmlLogRecord[remoteLogRecords.size()]);
      writeRecords(remoteLogRecordsArray);
    }
  }
 else {
    List<Any> anyLogRecords=new ArrayList<Any>();
    for (int i=0; i < logRecords.length; i++) {
      if (i < getBufferSize()) {
        try {
          Any anyLogRecord=orb.create_any();
          anyLogRecord=logFormatter.formatAny(anyLogRecord,logRecords[i]);
          anyLogRecords.add(anyLogRecord);
          candidateLogRecords.add(logRecords[i]);
        }
 catch (        RuntimeException e) {
          failures.addSerializationFailure(logRecords[i]);
        }
      }
 else {
        failures.addSendFailure(logRecords[i]);
      }
    }
    if (!anyLogRecords.isEmpty()) {
      Any[] anyLogRecordsArray=anyLogRecords.toArray(new Any[anyLogRecords.size()]);
      try {
        writeRecords(anyLogRecordsArray);
      }
 catch (      Throwable thr) {
        failures.addSendFailures(candidateLogRecords);
      }
    }
  }
  return failures;
}