Program: 17444
Project: 17444
Buggy source:
private void handleToken(IToken token,String contentType){
  try {
    if (token.getData() instanceof TagData) {
      TagData data=(TagData)token.getData();
      int start=fScanner.getTokenOffset();
      int length=data.getFirstPartitionEnd();
      String rawData=data.getRawData().toLowerCase();
      CFEPartition p=new CFEPartition(start,length,data.getStartPartitionType());
      if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
        fDocument.addPosition(fPositionCategory,p);
      }
      if (!data.isCloser()) {
        start=start + data.getFirstPartitionEnd();
        length=data.getMidPartitionEnd() - data.getFirstPartitionEnd();
        if (length > 0) {
          p=new CFEPartition(start,length,data.getMidPartitionType());
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
        }
        start=start + data.getMidPartitionEnd() - data.getFirstPartitionEnd();
        length=data.getRawData().length() - data.getMidPartitionEnd();
        if (length > 0 && data.getMidPartitionEnd() >= data.getFirstPartitionEnd()) {
          p=new CFEPartition(start,length,data.getEndPartitionType());
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
        }
        Set keys=fPseudoPartitions.keySet();
        Object[] tags=keys.toArray();
        for (int i=0; i < tags.length; i++) {
          String tag="String_Node_Str" + tags[i].toString();
          if (rawData.startsWith(tag)) {
            fPseudoPartition=fPseudoPartitions.getProperty(tags[i].toString());
            p.setNextPartitionType(fPseudoPartition);
            fPseudoPartitionStart=fScanner.getTokenOffset() + fScanner.getTokenLength();
            break;
          }
        }
        if (fPseudoPartition != null && !p.getNextPartitionType().equals(fPseudoPartition)) {
          p.setNextPartitionType(fPseudoPartition);
          length=fScanner.getTokenOffset() - fPseudoPartitionStart;
          p=new CFEPartition(fPseudoPartitionStart,length,fPseudoPartition);
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
          fPseudoPartitionStart=fScanner.getTokenOffset() + fScanner.getTokenLength();
        }
      }
 else {
        if (fPseudoPartition != null) {
          Set keys=fPseudoPartitions.keySet();
          Object[] tags=keys.toArray();
          for (int i=0; i < tags.length; i++) {
            String tag="String_Node_Str" + tags[i].toString();
            if (rawData.startsWith(tag)) {
              length=fScanner.getTokenOffset() - fPseudoPartitionStart;
              p=new CFEPartition(fPseudoPartitionStart,length,fPseudoPartition);
              if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
                fDocument.addPosition(fPositionCategory,p);
                System.out.println("String_Node_Str" + fPseudoPartition + "String_Node_Str"+ fPseudoPartitionStart+ "String_Node_Str"+ Integer.toString(p.getOffset() + p.getLength()));
              }
              fPseudoPartition=null;
              fPseudoPartitionStart=-1;
            }
          }
          if (fPseudoPartition != null) {
            System.out.println("String_Node_Str" + rawData + "String_Node_Str");
            length=fScanner.getTokenOffset() - fPseudoPartitionStart;
            p=new CFEPartition(fPseudoPartitionStart,length,fPseudoPartition);
            if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
              fDocument.addPosition(fPositionCategory,p);
              System.out.println("String_Node_Str" + fPseudoPartition + "String_Node_Str"+ p.getOffset()+ "String_Node_Str"+ Integer.toString(p.getOffset() + p.getLength())+ "String_Node_Str"+ rawData);
            }
            fPseudoPartitionStart=fScanner.getTokenOffset() + fScanner.getTokenLength();
            System.out.println("String_Node_Str" + fPseudoPartitionStart);
          }
        }
      }
    }
 else {
      CFEPartition p=new CFEPartition(fScanner.getTokenOffset(),fScanner.getTokenLength(),contentType);
      if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
        fDocument.addPosition(fPositionCategory,p);
      }
    }
  }
 catch (  BadLocationException e) {
    e.printStackTrace();
  }
catch (  BadPositionCategoryException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void handleToken(IToken token,String contentType){
  try {
    if (token.getData() instanceof TagData) {
      TagData data=(TagData)token.getData();
      int start=fScanner.getTokenOffset();
      int length=data.getFirstPartitionEnd();
      String rawData=data.getRawData().toLowerCase();
      CFEPartition p=new CFEPartition(start,length,data.getStartPartitionType());
      if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
        fDocument.addPosition(fPositionCategory,p);
      }
      if (!data.isCloser()) {
        start=start + data.getFirstPartitionEnd();
        length=data.getMidPartitionEnd() - data.getFirstPartitionEnd();
        if (length > 0) {
          p=new CFEPartition(start,length,data.getMidPartitionType());
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
        }
        start=start + data.getMidPartitionEnd() - data.getFirstPartitionEnd();
        length=data.getRawData().length() - data.getMidPartitionEnd();
        if (length > 0 && data.getMidPartitionEnd() >= data.getFirstPartitionEnd()) {
          p=new CFEPartition(start,length,data.getEndPartitionType());
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
        }
        Set keys=fPseudoPartitions.keySet();
        Object[] tags=keys.toArray();
        for (int i=0; i < tags.length; i++) {
          String tag="String_Node_Str" + tags[i].toString();
          if (rawData.startsWith(tag) && !Character.isLetter(rawData.charAt(tag.length()))) {
            fPseudoPartition=fPseudoPartitions.getProperty(tags[i].toString());
            p.setNextPartitionType(fPseudoPartition);
            fPseudoPartitionStart=fScanner.getTokenOffset() + fScanner.getTokenLength();
            break;
          }
        }
        if (fPseudoPartition != null && !p.getNextPartitionType().equals(fPseudoPartition)) {
          p.setNextPartitionType(fPseudoPartition);
          length=fScanner.getTokenOffset() - fPseudoPartitionStart;
          p=new CFEPartition(fPseudoPartitionStart,length,fPseudoPartition);
          if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
            fDocument.addPosition(fPositionCategory,p);
          }
          fPseudoPartitionStart=fScanner.getTokenOffset() + fScanner.getTokenLength();
        }
      }
 else {
        if (fPseudoPartition != null) {
          Set keys=fPseudoPartitions.keySet();
          Object[] tags=keys.toArray();
          for (int i=0; i < tags.length; i++) {
            String tag="String_Node_Str" + tags[i].toString();
            if (rawData.startsWith(tag) && !Character.isLetter(rawData.charAt(tag.length()))) {
              length=fScanner.getTokenOffset() - fPseudoPartitionStart;
              p=new CFEPartition(fPseudoPartitionStart,length,fPseudoPartition);
              if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
                fDocument.addPosition(fPositionCategory,p);
              }
              fPseudoPartition=null;
              fPseudoPartitionStart=-1;
            }
          }
          if (fPseudoPartition != null) {
            length=fScanner.getTokenOffset() - fPseudoPartitionStart;
            p=new CFEPartition(fPseudoPartitionStart,length,fPseudoPartition);
            if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
              fDocument.addPosition(fPositionCategory,p);
            }
            fPseudoPartitionStart=fScanner.getTokenOffset() + fScanner.getTokenLength();
          }
        }
      }
    }
 else {
      CFEPartition p=new CFEPartition(fScanner.getTokenOffset(),fScanner.getTokenLength(),contentType);
      if (!fDocument.containsPosition(fPositionCategory,p.offset,p.length)) {
        fDocument.addPosition(fPositionCategory,p);
      }
    }
  }
 catch (  BadLocationException e) {
    e.printStackTrace();
  }
catch (  BadPositionCategoryException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
}