Program: 135064
Project: 135064
Buggy source:
/** 
 * The method executes the search for both the public overloaded  find methods.
 * @param regExp The regular expression to look for in the logsnull if the method search for a string 
 * @param searchString The string to look for in the logsnull if the method search for a reg exp
 * @param caseSensitive If true performs a CaseSensitive searchIgnored for reg exp searchs (it is coded in the Pattern)
 * @param wholeWord If true look for the whole word int the columnIgnored for reg exp searchs
 * @param forwardSearch If true search forward otherwise backward
 * @param cols The columns of each log tool for the string
 * @return -1 if no log is found otherwise the row containing the string/reg exp
 */
private int find(Pattern regExp,String searchString,boolean caseSensitive,boolean wholeWord,boolean forwardSearch,boolean[] cols){
  int startingRow=getStartingRow(forwardSearch);
  int endRow=(forwardSearch) ? logEntryTable.getRowCount() - 1 : 0;
  FieldPosition pos=new java.text.FieldPosition(0);
  StringBuffer tempSB=new StringBuffer();
  int cursor=startingRow;
  if (endRow < startingRow) {
    int temp=startingRow;
    startingRow=endRow;
    endRow=temp;
  }
  int foundRow=-1;
  while (cursor >= startingRow && cursor <= endRow && foundRow == -1) {
    ILogEntry log=logTableDataModel.getVisibleLogEntry(cursor);
    String string=null;
    for (int t=0; t < cols.length - 1; t++) {
      Object obj=log.getField(t);
      if (obj == null) {
        continue;
      }
      if (cols[t]) {
switch (t) {
case ILogEntry.FIELD_TIMESTAMP:
{
            SimpleDateFormat df=new SimpleDateFormat(ILogEntry.TIME_FORMAT);
            Date dt=(Date)obj;
            tempSB.delete(0,tempSB.length());
            df.format(dt,tempSB,pos);
            string=tempSB.toString();
            break;
          }
case ILogEntry.FIELD_ENTRYTYPE:
case ILogEntry.FIELD_LINE:
case ILogEntry.FIELD_PRIORITY:
case ILogEntry.FIELD_STACKLEVEL:
{
          string="String_Node_Str" + ILogEntry.FIELD_ENTRYTYPE;
          break;
        }
default :
{
        string=obj.toString();
        break;
      }
  }
  if (matches(string,regExp,searchString,caseSensitive,wholeWord)) {
    if ((forwardSearch && cursor != startingRow) || (!forwardSearch && cursor != endRow)) {
      foundRow=cursor;
      if (forwardSearch) {
        cursor++;
      }
 else {
        cursor--;
      }
      return foundRow;
    }
  }
}
}
if (cols[cols.length - 1] && log.hasDatas()) {
Vector<ILogEntry.AdditionalData> addData=log.getAdditionalData();
for (int t=0; t < addData.size(); t++) {
  ILogEntry.AdditionalData data=addData.elementAt(t);
  string=data.getName();
  if (matches(string,regExp,searchString,caseSensitive,wholeWord)) {
    if ((forwardSearch && cursor != startingRow) || (!forwardSearch && cursor != endRow)) {
      foundRow=cursor;
      if (forwardSearch) {
        cursor++;
      }
 else {
        cursor--;
      }
      return foundRow;
    }
  }
  string=data.getValue();
  if (matches(string,regExp,searchString,caseSensitive,wholeWord)) {
    if ((forwardSearch && cursor != startingRow) || (!forwardSearch && cursor != endRow)) {
      foundRow=cursor;
      if (forwardSearch) {
        cursor++;
      }
 else {
        cursor--;
      }
      return foundRow;
    }
  }
}
}
if (forwardSearch) {
cursor++;
}
 else {
cursor--;
}
}
return foundRow;
}

Fixed version (ground truth):
/** 
 * The method executes the search for both the public overloaded  find methods.
 * @param regExp The regular expression to look for in the logsnull if the method search for a string 
 * @param searchString The string to look for in the logsnull if the method search for a reg exp
 * @param caseSensitive If true performs a CaseSensitive searchIgnored for reg exp searchs (it is coded in the Pattern)
 * @param wholeWord If true look for the whole word int the columnIgnored for reg exp searchs
 * @param forwardSearch If true search forward otherwise backward
 * @param cols The columns of each log tool for the string
 * @return -1 if no log is found otherwise the row containing the string/reg exp
 */
private int find(Pattern regExp,String searchString,boolean caseSensitive,boolean wholeWord,boolean forwardSearch,boolean[] cols){
  int startingRow=getStartingRow(forwardSearch);
  int endRow=(forwardSearch) ? logEntryTable.getRowCount() - 1 : 0;
  FieldPosition pos=new java.text.FieldPosition(0);
  StringBuffer tempSB=new StringBuffer();
  int cursor=startingRow;
  if (endRow < startingRow) {
    int temp=startingRow;
    startingRow=endRow;
    endRow=temp;
  }
  int foundRow=-1;
  while (cursor >= startingRow && cursor <= endRow && foundRow == -1) {
    ILogEntry log=logTableDataModel.getVisibleLogEntry(cursor);
    String string=null;
    for (int t=0; t < cols.length - 1; t++) {
      Object obj=log.getField(t);
      if (obj == null) {
        continue;
      }
      if (cols[t]) {
switch (t) {
case ILogEntry.FIELD_TIMESTAMP:
{
            SimpleDateFormat df=new SimpleDateFormat(ILogEntry.TIME_FORMAT);
            Date dt=(Date)obj;
            tempSB.delete(0,tempSB.length());
            df.format(dt,tempSB,pos);
            string=tempSB.toString();
            break;
          }
case ILogEntry.FIELD_ENTRYTYPE:
case ILogEntry.FIELD_LINE:
case ILogEntry.FIELD_PRIORITY:
case ILogEntry.FIELD_STACKLEVEL:
{
          string=obj.toString();
          break;
        }
default :
{
        string=obj.toString();
        break;
      }
  }
  if (matches(string,regExp,searchString,caseSensitive,wholeWord)) {
    if ((forwardSearch && cursor != startingRow) || (!forwardSearch && cursor != endRow)) {
      foundRow=cursor;
      if (forwardSearch) {
        cursor++;
      }
 else {
        cursor--;
      }
      return foundRow;
    }
  }
}
}
if (cols[cols.length - 1] && log.hasDatas()) {
Vector<ILogEntry.AdditionalData> addData=log.getAdditionalData();
for (int t=0; t < addData.size(); t++) {
  ILogEntry.AdditionalData data=addData.elementAt(t);
  string=data.getName();
  if (matches(string,regExp,searchString,caseSensitive,wholeWord)) {
    if ((forwardSearch && cursor != startingRow) || (!forwardSearch && cursor != endRow)) {
      foundRow=cursor;
      if (forwardSearch) {
        cursor++;
      }
 else {
        cursor--;
      }
      return foundRow;
    }
  }
  string=data.getValue();
  if (matches(string,regExp,searchString,caseSensitive,wholeWord)) {
    if ((forwardSearch && cursor != startingRow) || (!forwardSearch && cursor != endRow)) {
      foundRow=cursor;
      if (forwardSearch) {
        cursor++;
      }
 else {
        cursor--;
      }
      return foundRow;
    }
  }
}
}
if (forwardSearch) {
cursor++;
}
 else {
cursor--;
}
}
return foundRow;
}