Program: 35461
Project: 35461
Buggy source:
@SuppressWarnings("String_Node_Str") public static List<TrafficMessageData> parse(String message,String cs,TmcSegmentsCollection tmcSegments,TrafficLocationGraph graph){
  ArrayList<TrafficMessageData> messages=new ArrayList<TrafficMessageData>();
  try {
    DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder();
    InputStream stream=new ByteArrayInputStream(message.getBytes(cs));
    Document doc=docBuilder.parse(stream);
    String timeStamp="String_Node_Str";
    ArrayList<String> messageDataText=new ArrayList<String>();
    ArrayList<Integer> locationCodes=new ArrayList<Integer>();
    ArrayList<Integer> eventDataCodes=new ArrayList<Integer>();
    ArrayList<Coordinate> locations=new ArrayList<Coordinate>();
    String startTime=null;
    String endTime=null;
    String uptTime=null;
    String expTime=null;
    doc.getDocumentElement().normalize();
    timeStamp=doc.getDocumentElement().getAttribute("String_Node_Str");
    System.out.println("String_Node_Str" + timeStamp);
    NodeList listOfINFs=doc.getElementsByTagName("String_Node_Str");
    for (int i=0; i < listOfINFs.getLength(); i++) {
      Node ifn=listOfINFs.item(i);
      Element ifnElement=(Element)ifn;
      NodeList listOfMNGs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfMNGs.getLength(); j++) {
        Node mng=listOfMNGs.item(j);
        NodeList mngChildNodes=mng.getChildNodes();
        for (int a=0; a < mngChildNodes.getLength(); a++) {
          Node mngChild=mngChildNodes.item(a);
          if (mngChild.getNodeName().equals("String_Node_Str")) {
            uptTime=mngChild.getTextContent();
          }
 else           if (mngChild.getNodeName().equals("String_Node_Str")) {
            expTime=mngChild.getTextContent();
          }
        }
      }
      NodeList listOfMESs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfMESs.getLength(); j++) {
        Node mes=listOfMESs.item(j);
        Element mesElement=(Element)mes;
        if (mes.getParentNode().getNodeName().equals("String_Node_Str")) {
          NodeList listOfMDAs=mesElement.getElementsByTagName("String_Node_Str");
          for (int k=0; k < listOfMDAs.getLength(); k++) {
            Node mda=listOfMDAs.item(k);
            NodeList mdaChildNodes=mda.getChildNodes();
            for (int a=0; a < mdaChildNodes.getLength(); a++) {
              Node mdaChild=mdaChildNodes.item(a);
              if (mdaChild.getNodeName().equals("String_Node_Str")) {
                String msg=mdaChild.getTextContent();
                if (!Helper.isEmpty(msg)) {
                  messageDataText.add(msg);
                  break;
                }
              }
            }
          }
        }
      }
      NodeList listOfTTIs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfTTIs.getLength(); j++) {
        Node tti=listOfTTIs.item(j);
        NodeList tsChildNodes=tti.getChildNodes();
        for (int k=0; k < tsChildNodes.getLength(); k++) {
          Node tsChild=tsChildNodes.item(k);
          if (tsChild.getNodeName().equals("String_Node_Str")) {
            startTime=tsChild.getTextContent();
          }
          if (tsChild.getNodeName().equals("String_Node_Str")) {
            endTime=tsChild.getTextContent();
          }
        }
      }
      NodeList listOfLCDs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfLCDs.getLength(); j++) {
        locationCodes.add(Integer.parseInt(listOfLCDs.item(j).getTextContent()));
      }
      NodeList listOfECOs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfECOs.getLength(); j++) {
        eventDataCodes.add(Integer.parseInt(listOfECOs.item(j).getTextContent()));
      }
      NodeList listOfLDRs=ifnElement.getElementsByTagName("String_Node_Str");
      int direction=Integer.parseInt(listOfLDRs.item(0).getTextContent());
      boolean bothDirections=ifnElement.getElementsByTagName("String_Node_Str").item(0).getTextContent().equals("String_Node_Str");
      if (eventDataCodes.size() == 0)       eventDataCodes.add(1);
      if (locationCodes.size() == 1 && locationCodes.get(0).equals("String_Node_Str")) {
        NodeList listOfLCO=ifnElement.getElementsByTagName("String_Node_Str");
        for (int j=0; j < listOfLCO.getLength(); j++) {
          NodeList locChildNodes=listOfLCO.item(j).getChildNodes();
          int xi=0;
          int yi=1;
          if (locChildNodes.getLength() == 4) {
            xi=1;
            yi=3;
          }
          double loc_lon=Float.parseFloat(locChildNodes.item(xi).getTextContent()) / 100000.0;
          double loc_lat=Float.parseFloat(locChildNodes.item(yi).getTextContent()) / 100000.0;
          locations.add(new Coordinate(loc_lon,loc_lat));
        }
      }
      List<String> msgText=((ArrayList<String>)messageDataText.clone());
      if (locationCodes.size() == 1) {
        locationCodes.clear();
        double thresholdDistance=10.0;
        for (        Coordinate c : locations) {
          TmcSegment seg=tmcSegments.getClosestSegment(c,thresholdDistance);
          if (seg != null) {
            if (!locationCodes.contains(seg.getFrom()))             locationCodes.add(seg.getFrom());
            if (!locationCodes.contains(seg.getTo()))             locationCodes.add(seg.getTo());
          }
        }
        if (locationCodes.size() > 1) {
          List<Integer> lcList=new ArrayList<Integer>(locationCodes);
          List<Integer> evtList=new ArrayList<Integer>(eventDataCodes);
          TrafficMessageData m=new TrafficMessageData();
          m.messageDataText=msgText;
          m.locationCodes=lcList;
          m.eventDataCodes=evtList;
          m.direction=direction;
          m.bothDirections=bothDirections;
          m.startTime=startTime;
          m.endTime=endTime;
          m.uptTime=uptTime;
          m.expTime=expTime;
          messages.add(m);
        }
      }
 else {
        if ((locationCodes.size() > 0) && (eventDataCodes.size() > 0)) {
          if (direction == 1) {
            Collections.reverse(locationCodes);
          }
          List<Integer> lcList=new ArrayList<Integer>(locationCodes);
          List<Integer> evtList=new ArrayList<Integer>(eventDataCodes);
          for (int mi=0; mi < lcList.size() - 1; mi++) {
            int sCode=lcList.get(mi);
            int eCode=lcList.get(mi + 1);
            List<Integer> lcList1=getCodeList(graph,sCode,eCode);
            TrafficMessageData m=new TrafficMessageData();
            m.messageDataText=msgText;
            m.locationCodes=lcList1;
            m.eventDataCodes=evtList;
            m.direction=direction;
            m.bothDirections=bothDirections;
            m.startTime=startTime;
            m.endTime=endTime;
            m.uptTime=uptTime;
            m.expTime=expTime;
            if (locationCodes.size() == 1 && locations.size() == 1) {
              m.location=locations.get(0);
            }
            messages.add(m);
          }
        }
      }
      messageDataText.clear();
      locationCodes.clear();
      eventDataCodes.clear();
      locations.clear();
      startTime=null;
      endTime=null;
      uptTime=null;
      expTime=null;
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  return messages;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static List<TrafficMessageData> parse(String message,String cs,TmcSegmentsCollection tmcSegments,TrafficLocationGraph graph){
  ArrayList<TrafficMessageData> messages=new ArrayList<TrafficMessageData>();
  try {
    DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder();
    InputStream stream=new ByteArrayInputStream(message.getBytes(cs));
    Document doc=docBuilder.parse(stream);
    String timeStamp="String_Node_Str";
    ArrayList<String> messageDataText=new ArrayList<String>();
    ArrayList<Integer> locationCodes=new ArrayList<Integer>();
    ArrayList<Integer> eventDataCodes=new ArrayList<Integer>();
    ArrayList<Coordinate> locations=new ArrayList<Coordinate>();
    String startTime=null;
    String endTime=null;
    String uptTime=null;
    String expTime=null;
    doc.getDocumentElement().normalize();
    timeStamp=doc.getDocumentElement().getAttribute("String_Node_Str");
    System.out.println("String_Node_Str" + timeStamp);
    NodeList listOfINFs=doc.getElementsByTagName("String_Node_Str");
    for (int i=0; i < listOfINFs.getLength(); i++) {
      Node ifn=listOfINFs.item(i);
      Element ifnElement=(Element)ifn;
      NodeList listOfMNGs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfMNGs.getLength(); j++) {
        Node mng=listOfMNGs.item(j);
        NodeList mngChildNodes=mng.getChildNodes();
        for (int a=0; a < mngChildNodes.getLength(); a++) {
          Node mngChild=mngChildNodes.item(a);
          if (mngChild.getNodeName().equals("String_Node_Str")) {
            uptTime=mngChild.getTextContent();
          }
 else           if (mngChild.getNodeName().equals("String_Node_Str")) {
            expTime=mngChild.getTextContent();
          }
        }
      }
      NodeList listOfMESs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfMESs.getLength(); j++) {
        Node mes=listOfMESs.item(j);
        Element mesElement=(Element)mes;
        if (mes.getParentNode().getNodeName().equals("String_Node_Str")) {
          NodeList listOfMDAs=mesElement.getElementsByTagName("String_Node_Str");
          for (int k=0; k < listOfMDAs.getLength(); k++) {
            Node mda=listOfMDAs.item(k);
            NodeList mdaChildNodes=mda.getChildNodes();
            for (int a=0; a < mdaChildNodes.getLength(); a++) {
              Node mdaChild=mdaChildNodes.item(a);
              if (mdaChild.getNodeName().equals("String_Node_Str")) {
                String msg=mdaChild.getTextContent();
                if (!Helper.isEmpty(msg)) {
                  messageDataText.add(msg);
                  break;
                }
              }
            }
          }
        }
      }
      NodeList listOfTTIs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfTTIs.getLength(); j++) {
        Node tti=listOfTTIs.item(j);
        NodeList tsChildNodes=tti.getChildNodes();
        for (int k=0; k < tsChildNodes.getLength(); k++) {
          Node tsChild=tsChildNodes.item(k);
          if (tsChild.getNodeName().equals("String_Node_Str")) {
            startTime=tsChild.getTextContent();
          }
          if (tsChild.getNodeName().equals("String_Node_Str")) {
            endTime=tsChild.getTextContent();
          }
        }
      }
      NodeList listOfLCDs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfLCDs.getLength(); j++) {
        String lcdStr=listOfLCDs.item(j).getTextContent();
        if (isParsable(lcdStr))         locationCodes.add(Integer.parseInt(lcdStr));
      }
      NodeList listOfECOs=ifnElement.getElementsByTagName("String_Node_Str");
      for (int j=0; j < listOfECOs.getLength(); j++) {
        eventDataCodes.add(Integer.parseInt(listOfECOs.item(j).getTextContent()));
      }
      NodeList listOfLDRs=ifnElement.getElementsByTagName("String_Node_Str");
      int direction=Integer.parseInt(listOfLDRs.item(0).getTextContent());
      boolean bothDirections=ifnElement.getElementsByTagName("String_Node_Str").item(0).getTextContent().equals("String_Node_Str");
      if (eventDataCodes.size() == 0)       eventDataCodes.add(1);
      if (locationCodes.size() == 1 && locationCodes.get(0).equals("String_Node_Str")) {
        NodeList listOfLCO=ifnElement.getElementsByTagName("String_Node_Str");
        for (int j=0; j < listOfLCO.getLength(); j++) {
          NodeList locChildNodes=listOfLCO.item(j).getChildNodes();
          int xi=0;
          int yi=1;
          if (locChildNodes.getLength() == 4) {
            xi=1;
            yi=3;
          }
          double loc_lon=Float.parseFloat(locChildNodes.item(xi).getTextContent()) / 100000.0;
          double loc_lat=Float.parseFloat(locChildNodes.item(yi).getTextContent()) / 100000.0;
          locations.add(new Coordinate(loc_lon,loc_lat));
        }
      }
      List<String> msgText=((ArrayList<String>)messageDataText.clone());
      if (locationCodes.size() == 1) {
        locationCodes.clear();
        double thresholdDistance=10.0;
        for (        Coordinate c : locations) {
          TmcSegment seg=tmcSegments.getClosestSegment(c,thresholdDistance);
          if (seg != null) {
            if (!locationCodes.contains(seg.getFrom()))             locationCodes.add(seg.getFrom());
            if (!locationCodes.contains(seg.getTo()))             locationCodes.add(seg.getTo());
          }
        }
        if (locationCodes.size() > 1) {
          List<Integer> lcList=new ArrayList<Integer>(locationCodes);
          List<Integer> evtList=new ArrayList<Integer>(eventDataCodes);
          TrafficMessageData m=new TrafficMessageData();
          m.messageDataText=msgText;
          m.locationCodes=lcList;
          m.eventDataCodes=evtList;
          m.direction=direction;
          m.bothDirections=bothDirections;
          m.startTime=startTime;
          m.endTime=endTime;
          m.uptTime=uptTime;
          m.expTime=expTime;
          messages.add(m);
        }
      }
 else {
        if ((locationCodes.size() > 0) && (eventDataCodes.size() > 0)) {
          if (direction == 1) {
            Collections.reverse(locationCodes);
          }
          List<Integer> lcList=new ArrayList<Integer>(locationCodes);
          List<Integer> evtList=new ArrayList<Integer>(eventDataCodes);
          for (int mi=0; mi < lcList.size() - 1; mi++) {
            int sCode=lcList.get(mi);
            int eCode=lcList.get(mi + 1);
            List<Integer> lcList1=getCodeList(graph,sCode,eCode);
            TrafficMessageData m=new TrafficMessageData();
            m.messageDataText=msgText;
            m.locationCodes=lcList1;
            m.eventDataCodes=evtList;
            m.direction=direction;
            m.bothDirections=bothDirections;
            m.startTime=startTime;
            m.endTime=endTime;
            m.uptTime=uptTime;
            m.expTime=expTime;
            if (locationCodes.size() == 1 && locations.size() == 1) {
              m.location=locations.get(0);
            }
            messages.add(m);
          }
        }
      }
      messageDataText.clear();
      locationCodes.clear();
      eventDataCodes.clear();
      locations.clear();
      startTime=null;
      endTime=null;
      uptTime=null;
      expTime=null;
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  return messages;
}