Program: 17452
Project: 17452
Buggy source:
/** 
 * @param offset - Offset from which to start looking for partitions
 * @param data - The raw data from an instance of TagData. Used to determine if the tag is a closer or opener
 * @param indexOffset - Indicates the difference between the first andend partitions spanned by the TagData instance. 
 * @return The next partition type.
 */
private String getNextPartitionType(int offset,String data,int indexOffset){
  try {
    boolean opener=false;
    boolean closer=false;
    String next=opensPseudoPartition(data);
    if (next != null) {
      opener=true;
    }
    String closes=closesPseudoPartition(data);
    if (closes != null) {
      next=null;
      closer=true;
    }
    Position[] category=fDocument.getPositions(fPositionCategory);
    int index=fDocument.computeIndexInCategory(fPositionCategory,offset);
    CFEPartition firstPartition=(CFEPartition)category[index];
    CFEPartition endPartition=(CFEPartition)category[index + indexOffset];
    if (opener) {
      endPartition.setOpensPartition(next);
    }
    if (closer) {
      endPartition.setClosesPartition(closes);
    }
    if (index > 0) {
      CFEPartition prevPartition=(CFEPartition)category[index - 1];
      if (next == null && !closer) {
        next=prevPartition.getNextPartitionType();
      }
      if (firstPartition.offset > prevPartition.offset + prevPartition.length && prevPartition.getNextPartitionType() != null) {
        int start=prevPartition.offset + prevPartition.length;
        int length=firstPartition.offset - start;
        CFEPartition p=new CFEPartition(start,length,prevPartition.getNextPartitionType());
        p.setNextPartitionType(prevPartition.getNextPartitionType());
        fDocument.addPosition(fPositionCategory,p);
      }
    }
    if (index + 1 + indexOffset < category.length) {
      CFEPartition nextPartition=(CFEPartition)category[index + indexOffset + 1];
      if (next != null) {
        if (nextPartition.getType().equals(next)) {
          nextPartition.setOffset(endPartition.offset + endPartition.length);
        }
 else         if (endPartition.offset + endPartition.length < nextPartition.offset) {
          int start=endPartition.offset + endPartition.length;
          int length=nextPartition.offset - start;
          CFEPartition p=new CFEPartition(start,length,next);
          p.setNextPartitionType(next);
          fDocument.addPosition(fPositionCategory,p);
        }
      }
 else       if (nextPartition.getType() != null && isPseudoPartition(nextPartition.getType())) {
        int i=index + indexOffset + 1;
        while (i < category.length) {
          nextPartition=(CFEPartition)category[i];
          if (isPseudoPartition(nextPartition.getType())) {
            rememberRegion(nextPartition.offset,nextPartition.length);
            fDocument.removePosition(fPositionCategory,nextPartition);
          }
 else           if (nextPartition.getOpensPartitionType() != null) {
            break;
          }
          ++i;
        }
      }
    }
    return next;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param offset - Offset from which to start looking for partitions
 * @param data - The raw data from an instance of TagData. Used to determine if the tag is a closer or opener
 * @param indexOffset - Indicates the difference between the first andend partitions spanned by the TagData instance. 
 * @return The next partition type.
 */
private String getNextPartitionType(int offset,String data,int indexOffset){
  try {
    boolean opener=false;
    boolean closer=false;
    String next=opensPseudoPartition(data);
    if (next != null) {
      opener=true;
    }
    String closes=closesPseudoPartition(data);
    if (closes != null) {
      next=null;
      closer=true;
    }
    Position[] category=fDocument.getPositions(fPositionCategory);
    int index=fDocument.computeIndexInCategory(fPositionCategory,offset);
    CFEPartition firstPartition=(CFEPartition)category[index];
    CFEPartition endPartition=(CFEPartition)category[index + indexOffset];
    if (opener) {
      endPartition.setOpensPartition(next);
    }
    if (closer) {
      endPartition.setClosesPartition(closes);
    }
    if (index > 0) {
      CFEPartition prevPartition=(CFEPartition)category[index - 1];
      if (next == null && !closer) {
        next=prevPartition.getNextPartitionType();
      }
      if (firstPartition.offset > prevPartition.offset + prevPartition.length && prevPartition.getNextPartitionType() != null) {
        int start=prevPartition.offset + prevPartition.length;
        int length=firstPartition.offset - start;
        CFEPartition p=new CFEPartition(start,length,prevPartition.getNextPartitionType());
        p.setNextPartitionType(prevPartition.getNextPartitionType());
        fDocument.addPosition(fPositionCategory,p);
      }
 else       if (prevPartition.offset + prevPartition.length > firstPartition.offset) {
        prevPartition.length=firstPartition.offset - prevPartition.offset;
      }
      if (next != null && next.endsWith("String_Node_Str") && !next.startsWith("String_Node_Str") && endPartition.getType().equals(CFPartitionScanner.CF_END_TAG)) {
        int startOffset=endPartition.getOffset() + endPartition.getLength();
        int endOffset=fDocument.getLength();
        int currentOffset=startOffset;
        String doc=fDocument.get();
        while (currentOffset < endOffset) {
          char c=doc.charAt(currentOffset);
          if (c == '>') {
            String closerType=CFPartitionScanner.HTM_END_TAG;
            if (next == CFPartitionScanner.FORM_TAG_ATTRIBS) {
              closerType=CFPartitionScanner.FORM_END_TAG;
            }
 else             if (next == CFPartitionScanner.TABLE_TAG_ATTRIBS) {
              closerType=CFPartitionScanner.TABLE_END_TAG;
            }
            CFEPartition p=new CFEPartition(currentOffset,1,prevPartition.getNextPartitionType());
            fDocument.addPosition(fPositionCategory,p);
            break;
          }
          ++currentOffset;
        }
      }
    }
    if (index + 1 + indexOffset < category.length) {
      CFEPartition nextPartition=(CFEPartition)category[index + indexOffset + 1];
      if (next != null) {
        if (nextPartition.getType().equals(next)) {
          nextPartition.setOffset(endPartition.offset + endPartition.length);
        }
 else         if (endPartition.offset + endPartition.length < nextPartition.offset) {
          int start=endPartition.offset + endPartition.length;
          int length=nextPartition.offset - start;
          CFEPartition p=new CFEPartition(start,length,next);
          p.setNextPartitionType(next);
          fDocument.addPosition(fPositionCategory,p);
        }
      }
 else       if (nextPartition.getType() != null && isPseudoPartition(nextPartition.getType())) {
        int i=index + indexOffset + 1;
        while (i < category.length) {
          nextPartition=(CFEPartition)category[i];
          if (isPseudoPartition(nextPartition.getType())) {
            rememberRegion(nextPartition.offset,nextPartition.length);
            fDocument.removePosition(fPositionCategory,nextPartition);
          }
 else           if (nextPartition.getOpensPartitionType() != null) {
            break;
          }
          ++i;
        }
      }
    }
    return next;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}