Program: 80084
Project: 80084
Buggy source:
/** 
 * Test Blob.position() with blob argument
 */
public void testPositionBlob() throws Exception {
  insertDefaultData();
  Statement stmt=createStatement();
  ResultSet rs=stmt.executeQuery("String_Node_Str");
  int blobLength=0;
  Blob blob;
  Statement stmt2=createStatement();
  Random random=new Random();
  String searchString;
  int start, length, startSearchPos;
  int distance, maxStartPointDistance;
  long foundAt;
  maxStartPointDistance=CharAlphabet.MODERNLATINLOWER.length;
  while (rs.next()) {
    blob=rs.getBlob(1);
    blobLength=rs.getInt(2);
    if (blob != null && blobLength > 0) {
      println("String_Node_Str" + blobLength);
      stmt2.executeUpdate("String_Node_Str" + "String_Node_Str");
      PreparedStatement ps=prepareStatement("String_Node_Str");
      for (int i=0; i < 10; i++) {
        start=Math.max(random.nextInt(blobLength - 1),1);
        length=random.nextInt(blobLength - start) + 1;
        println("String_Node_Str" + start + "String_Node_Str"+ length);
        searchString=new String(blob.getBytes(start,length));
        distance=random.nextInt(maxStartPointDistance);
        startSearchPos=Math.max((start - distance),1);
        String tmp=new String(blob.getBytes(startSearchPos,start));
        if (tmp.indexOf(searchString) != -1) {
          startSearchPos=start;
        }
        ps.setBytes(1,searchString.getBytes());
        ps.setInt(2,startSearchPos);
        ps.setInt(3,start);
        ps.executeUpdate();
      }
      ps.close();
      ResultSet rs2=stmt2.executeQuery("String_Node_Str");
      while (rs2.next()) {
        Blob searchBlob=rs2.getBlob(1);
        startSearchPos=rs2.getInt(2);
        start=rs2.getInt(3);
        searchString=new String(searchBlob.getBytes(1L,(int)searchBlob.length()));
        println("String_Node_Str" + startSearchPos + "String_Node_Str"+ searchString);
        foundAt=blob.position(searchBlob,startSearchPos);
        assertEquals("String_Node_Str" + searchString + "String_Node_Str"+ startSearchPos+ "String_Node_Str"+ searchString.length(),start,foundAt);
      }
      rs2.close();
      stmt2.executeUpdate("String_Node_Str");
    }
  }
  rs.close();
  stmt.close();
  stmt2.close();
}

Fixed version (ground truth):
/** 
 * Test Blob.position() with blob argument
 */
public void testPositionBlob() throws Exception {
  insertDefaultData();
  Statement stmt=createStatement();
  ResultSet rs=stmt.executeQuery("String_Node_Str");
  int blobLength=0;
  Blob blob;
  Statement stmt2=createStatement();
  Random random=new Random();
  String searchString;
  int start, length, startSearchPos;
  int distance, maxStartPointDistance;
  long foundAt;
  maxStartPointDistance=CharAlphabet.MODERNLATINLOWER.length;
  while (rs.next()) {
    blob=rs.getBlob(1);
    blobLength=rs.getInt(2);
    if (blob != null && blobLength > 0) {
      println("String_Node_Str" + blobLength);
      stmt2.executeUpdate("String_Node_Str" + "String_Node_Str");
      PreparedStatement ps=prepareStatement("String_Node_Str");
      for (int i=0; i < 10; i++) {
        start=Math.max(random.nextInt(blobLength - 1),1);
        length=random.nextInt(blobLength - start) + 1;
        println("String_Node_Str" + start + "String_Node_Str"+ length);
        searchString=new String(blob.getBytes(start,length),"String_Node_Str");
        distance=random.nextInt(maxStartPointDistance);
        startSearchPos=Math.max((start - distance),1);
        String tmp=new String(blob.getBytes(startSearchPos,start),"String_Node_Str");
        if (tmp.indexOf(searchString) != -1) {
          startSearchPos=start;
        }
        ps.setBytes(1,searchString.getBytes("String_Node_Str"));
        ps.setInt(2,startSearchPos);
        ps.setInt(3,start);
        ps.executeUpdate();
      }
      ps.close();
      ResultSet rs2=stmt2.executeQuery("String_Node_Str");
      while (rs2.next()) {
        Blob searchBlob=rs2.getBlob(1);
        startSearchPos=rs2.getInt(2);
        start=rs2.getInt(3);
        searchString=new String(searchBlob.getBytes(1L,(int)searchBlob.length()),"String_Node_Str");
        println("String_Node_Str" + startSearchPos + "String_Node_Str"+ searchString);
        foundAt=blob.position(searchBlob,startSearchPos);
        assertEquals("String_Node_Str" + searchString + "String_Node_Str"+ startSearchPos+ "String_Node_Str"+ searchString.length(),start,foundAt);
      }
      rs2.close();
      stmt2.executeUpdate("String_Node_Str");
    }
  }
  rs.close();
  stmt.close();
  stmt2.close();
}