Program: 32297
Project: 32297
Buggy source:
void gpx(Device device,InputStream inputStream,HttpServletResponse response) throws IOException {
  TimeZone tz=TimeZone.getTimeZone("String_Node_Str");
  DateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
  DateFormat dateFormatWithMS=new SimpleDateFormat("String_Node_Str");
  dateFormatWithMS.setTimeZone(tz);
  try {
    XMLStreamReader xsr=XMLInputFactory.newFactory().createXMLStreamReader(inputStream);
    List<Position> parsedPositions=new LinkedList<Position>();
    Position position=null;
    response.getWriter().println("String_Node_Str");
    int imported=0;
    while (xsr.hasNext()) {
      xsr.next();
      if (xsr.getEventType() == XMLStreamReader.START_ELEMENT) {
        if (xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
          position=new Position();
          position.setLongitude(Double.parseDouble(xsr.getAttributeValue(null,"String_Node_Str")));
          position.setLatitude(Double.parseDouble(xsr.getAttributeValue(null,"String_Node_Str")));
          position.setValid(Boolean.TRUE);
          position.setDevice(device);
        }
 else         if (xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
          if (position != null) {
            String strTime=xsr.getElementText();
            if (strTime.length() == 20) {
              position.setTime(dateFormat.parse(strTime));
            }
 else {
              position.setTime(dateFormatWithMS.parse(strTime));
            }
          }
        }
 else         if (xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
          if (position != null) {
            position.setAltitude(Double.parseDouble(xsr.getElementText()));
          }
        }
 else         if (position != null) {
          position.setOther((position.getOther() == null ? "String_Node_Str" : position.getOther()) + "String_Node_Str" + xsr.getLocalName()+ "String_Node_Str"+ xsr.getElementText()+ "String_Node_Str"+ xsr.getLocalName()+ "String_Node_Str");
        }
      }
 else       if (xsr.getEventType() == XMLStreamReader.END_ELEMENT && xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
        parsedPositions.add(position);
        position=null;
      }
    }
    for (int i=0; i < parsedPositions.size(); i++) {
      position=parsedPositions.get(i);
      StringBuilder other=new StringBuilder("String_Node_Str");
      other.append("String_Node_Str");
      if (i == 0) {
        other.append("String_Node_Str");
      }
 else       if (i == parsedPositions.size() - 1) {
        other.append("String_Node_Str");
      }
 else {
        other.append("String_Node_Str");
      }
      other.append("String_Node_Str");
      if (position.getOther() != null) {
        other.append(position.getOther());
      }
      other.append("String_Node_Str");
      position.setOther(other.toString());
      boolean exist=false;
      for (      Position existing : entityManager.get().createQuery("String_Node_Str",Position.class).setParameter("String_Node_Str",device).setParameter("String_Node_Str",position.getTime()).getResultList()) {
        if (equals(existing.getLongitude(),position.getLongitude(),0.0000000001d) && equals(existing.getLatitude(),position.getLatitude(),0.0000000001d) && equals(existing.getAltitude(),position.getAltitude(),0.00001d)&& existing.getOther().equals(position.getOther())) {
          exist=true;
          break;
        }
      }
      if (!exist) {
        entityManager.get().persist(position);
        imported++;
      }
    }
    response.getWriter().println("String_Node_Str" + (parsedPositions.size() - imported));
    response.getWriter().println("String_Node_Str" + imported);
    response.getWriter().println("String_Node_Str");
  }
 catch (  XMLStreamException xse) {
    throw new IOException(xse);
  }
catch (  ParseException pe) {
    throw new IOException(pe);
  }
}

Fixed version (ground truth):
void gpx(Device device,InputStream inputStream,HttpServletResponse response) throws IOException {
  TimeZone tz=TimeZone.getTimeZone("String_Node_Str");
  DateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
  DateFormat dateFormatWithMS=new SimpleDateFormat("String_Node_Str");
  dateFormat.setTimeZone(tz);
  dateFormatWithMS.setTimeZone(tz);
  try {
    XMLStreamReader xsr=XMLInputFactory.newFactory().createXMLStreamReader(inputStream);
    List<Position> parsedPositions=new LinkedList<Position>();
    Position position=null;
    response.getWriter().println("String_Node_Str");
    int imported=0;
    while (xsr.hasNext()) {
      xsr.next();
      if (xsr.getEventType() == XMLStreamReader.START_ELEMENT) {
        if (xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
          position=new Position();
          position.setLongitude(Double.parseDouble(xsr.getAttributeValue(null,"String_Node_Str")));
          position.setLatitude(Double.parseDouble(xsr.getAttributeValue(null,"String_Node_Str")));
          position.setValid(Boolean.TRUE);
          position.setDevice(device);
        }
 else         if (xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
          if (position != null) {
            String strTime=xsr.getElementText();
            if (strTime.length() == 20) {
              position.setTime(dateFormat.parse(strTime));
            }
 else {
              position.setTime(dateFormatWithMS.parse(strTime));
            }
          }
        }
 else         if (xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
          if (position != null) {
            position.setAltitude(Double.parseDouble(xsr.getElementText()));
          }
        }
 else         if (position != null) {
          position.setOther((position.getOther() == null ? "String_Node_Str" : position.getOther()) + "String_Node_Str" + xsr.getLocalName()+ "String_Node_Str"+ xsr.getElementText()+ "String_Node_Str"+ xsr.getLocalName()+ "String_Node_Str");
        }
      }
 else       if (xsr.getEventType() == XMLStreamReader.END_ELEMENT && xsr.getLocalName().equalsIgnoreCase("String_Node_Str")) {
        parsedPositions.add(position);
        position=null;
      }
    }
    for (int i=0; i < parsedPositions.size(); i++) {
      position=parsedPositions.get(i);
      StringBuilder other=new StringBuilder("String_Node_Str");
      other.append("String_Node_Str");
      if (i == 0) {
        other.append("String_Node_Str");
      }
 else       if (i == parsedPositions.size() - 1) {
        other.append("String_Node_Str");
      }
 else {
        other.append("String_Node_Str");
      }
      other.append("String_Node_Str");
      if (position.getOther() != null) {
        other.append(position.getOther());
      }
      other.append("String_Node_Str");
      position.setOther(other.toString());
      boolean exist=false;
      for (      Position existing : entityManager.get().createQuery("String_Node_Str",Position.class).setParameter("String_Node_Str",device).setParameter("String_Node_Str",position.getTime()).getResultList()) {
        if (equals(existing.getLongitude(),position.getLongitude(),0.0000000001d) && equals(existing.getLatitude(),position.getLatitude(),0.0000000001d) && equals(existing.getAltitude(),position.getAltitude(),0.00001d)&& existing.getOther().equals(position.getOther())) {
          exist=true;
          break;
        }
      }
      if (!exist) {
        entityManager.get().persist(position);
        imported++;
      }
    }
    response.getWriter().println("String_Node_Str" + (parsedPositions.size() - imported));
    response.getWriter().println("String_Node_Str" + imported);
    response.getWriter().println("String_Node_Str");
  }
 catch (  XMLStreamException xse) {
    throw new IOException(xse);
  }
catch (  ParseException pe) {
    throw new IOException(pe);
  }
}