Program: 17450
Project: 17450
Buggy source:
/** 
 * @param token - The token that was found by the scanner
 * @param contentType - The content type of the token
 */
private String handleToken(IToken token,String contentType,String nextPartitionType){
  try {
    CFEPartition p=null;
    int length;
    int indexOffset=0;
    String rawData=null;
    if (token.getData() instanceof TagData) {
      TagData data=(TagData)token.getData();
      int start=fScanner.getTokenOffset();
      length=data.getFirstPartitionEnd();
      rawData=data.getRawData().toLowerCase();
      if (!fDocument.containsPosition(fPositionCategory,start,length)) {
        p=new CFEPartition(start,length,data.getStartPartitionType());
        fDocument.addPosition(fPositionCategory,p);
      }
      if (!data.isCloser()) {
        if (p != null) {
          p.setNextPartitionType(data.getMidPartitionType());
        }
        if (data.fHasMid) {
          indexOffset++;
          start=start + data.getFirstPartitionEnd();
          length=data.getMidPartitionEnd() - data.getFirstPartitionEnd();
          p=new CFEPartition(start,length,data.getMidPartitionType());
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
        }
 else {
        }
        if (data.fHasEnd) {
          indexOffset++;
          start=fScanner.getTokenOffset() + data.getMidPartitionEnd();
          length=data.getRawData().length() - data.getMidPartitionEnd();
          if (!fDocument.containsPosition(fPositionCategory,start,length)) {
            p=new CFEPartition(start,length,data.getEndPartitionType());
            fDocument.addPosition(fPositionCategory,p);
          }
        }
 else {
        }
      }
    }
 else {
      if (!fDocument.containsPosition(fPositionCategory,fScanner.getTokenOffset(),fScanner.getTokenLength())) {
        p=new CFEPartition(fScanner.getTokenOffset(),fScanner.getTokenLength(),contentType);
        fDocument.addPosition(fPositionCategory,p);
      }
    }
    if (p != null && p.getNextPartitionType() == null) {
      String next=getNextPartitionType(fScanner.getTokenOffset(),rawData,indexOffset);
      p.setNextPartitionType(next);
      return next;
    }
 else {
      return null;
    }
  }
 catch (  BadLocationException e) {
    e.printStackTrace();
  }
catch (  BadPositionCategoryException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param token - The token that was found by the scanner
 * @param contentType - The content type of the token
 */
private String handleToken(IToken token,String contentType,String nextPartitionType){
  try {
    CFEPartition p=null;
    int length;
    int indexOffset=0;
    String rawData=null;
    if (token.getData() instanceof TagData) {
      TagData data=(TagData)token.getData();
      int start=fScanner.getTokenOffset();
      length=data.getFirstPartitionEnd();
      rawData=data.getRawData().toLowerCase();
      if (!fDocument.containsPosition(fPositionCategory,start,length)) {
        p=new CFEPartition(start,length,data.getStartPartitionType());
        fDocument.addPosition(fPositionCategory,p);
      }
      if (!data.isCloser()) {
        if (p != null) {
          p.setNextPartitionType(data.getMidPartitionType());
        }
        if (data.fHasMid) {
          indexOffset++;
          start=start + data.getFirstPartitionEnd();
          length=data.getMidPartitionEnd() - data.getFirstPartitionEnd();
          p=new CFEPartition(start,length,data.getMidPartitionType());
          p.setNextPartitionType(p.getType());
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
        }
 else {
        }
        if (data.fHasEnd) {
          indexOffset++;
          start=fScanner.getTokenOffset() + data.getMidPartitionEnd();
          length=data.getRawData().length() - data.getMidPartitionEnd();
          if (!fDocument.containsPosition(fPositionCategory,start,length)) {
            p=new CFEPartition(start,length,data.getEndPartitionType());
            fDocument.addPosition(fPositionCategory,p);
          }
        }
 else {
        }
      }
    }
 else {
      if (!fDocument.containsPosition(fPositionCategory,fScanner.getTokenOffset(),fScanner.getTokenLength())) {
        p=new CFEPartition(fScanner.getTokenOffset(),fScanner.getTokenLength(),contentType);
        fDocument.addPosition(fPositionCategory,p);
      }
    }
    if (p != null && p.getNextPartitionType() == null) {
      String next=getNextPartitionType(fScanner.getTokenOffset(),rawData,indexOffset);
      p.setNextPartitionType(next);
      return next;
    }
 else {
      return null;
    }
  }
 catch (  BadLocationException e) {
    e.printStackTrace();
  }
catch (  BadPositionCategoryException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}