Program: 145257
Project: 145257
Buggy source:
private void reliableHttpPost(String url,int MD5,String contentType,IDataPayload pl) throws IOException, OtherIOException {
  boolean sendFailed;
  InputStream in=pl.getPayloadStream();
  int numTries=0;
  while (numTries < MAX_NUM_RETRIES) {
    numTries++;
    sendFailed=false;
    con=(HttpConnection)Connector.open(url);
    con.setRequestMethod(HttpConnection.POST);
    setDefaultRequestProperties(con);
    con.setRequestProperty("String_Node_Str",contentType);
    con.setRequestProperty("String_Node_Str",String.valueOf(MD5));
    out=con.openOutputStream();
    try {
      int c=inputStreamReadCastExceptions(in);
      while (c != -1) {
        out.write(c);
        c=inputStreamReadCastExceptions(in);
      }
      out.flush();
      int responseCode=con.getResponseCode();
      String ETag=con.getHeaderField("String_Node_Str");
      if (responseCode != HttpConnection.HTTP_OK) {
        if (ETag != null) {
          sendFailed=true;
        }
 else {
          throw new OtherIOException("String_Node_Str" + responseCode);
        }
      }
    }
 catch (    IOException e) {
      sendFailed=true;
    }
    if (sendFailed) {
      cleanUp(out);
      cleanUp(con);
      int lastByte=reliableRequestLastByte(url,MD5);
      if (lastByte != -1) {
        cleanUp(in);
        in=pl.getPayloadStream();
        in.skip(lastByte);
        continue;
      }
      cleanUp(in);
      in=pl.getPayloadStream();
      continue;
    }
    in.close();
    in=con.openInputStream();
    int len=(int)con.getLength();
    if (len > 0) {
      int actual=0;
      int bytesread=0;
      byte[] data=new byte[len];
      while ((bytesread != len) && (actual != -1)) {
        actual=in.read(data,bytesread,len - bytesread);
        bytesread+=actual;
      }
      process(data);
    }
 else {
      int ch;
      while ((ch=in.read()) != -1) {
        process((byte)ch);
      }
    }
    break;
  }
  if (numTries == MAX_NUM_RETRIES) {
    throw new IOException();
  }
}

Fixed version (ground truth):
private void reliableHttpPost(String url,int MD5,String contentType,IDataPayload pl) throws IOException, OtherIOException {
  boolean sendFailed;
  InputStream in=pl.getPayloadStream();
  int numTries=0;
  while (numTries < MAX_NUM_RETRIES) {
    numTries++;
    sendFailed=false;
    try {
      con=(HttpConnection)Connector.open(url);
      con.setRequestMethod(HttpConnection.POST);
      setDefaultRequestProperties(con);
      con.setRequestProperty("String_Node_Str",contentType);
      con.setRequestProperty("String_Node_Str",String.valueOf(MD5));
      out=con.openOutputStream();
    }
 catch (    IOException e) {
      throw new IOException("String_Node_Str");
    }
    try {
      int c=inputStreamReadCastExceptions(in);
      while (c != -1) {
        out.write(c);
        c=inputStreamReadCastExceptions(in);
      }
      out.flush();
      int responseCode=con.getResponseCode();
      String ETag=con.getHeaderField("String_Node_Str");
      if (responseCode != HttpConnection.HTTP_OK) {
        if (ETag != null) {
          sendFailed=true;
        }
 else {
          throw new OtherIOException("String_Node_Str" + responseCode);
        }
      }
    }
 catch (    IOException e) {
      sendFailed=true;
    }
    if (sendFailed) {
      cleanUp(out);
      cleanUp(con);
      int lastByte=reliableRequestLastByte(url,MD5);
      cleanUp(in);
      in=pl.getPayloadStream();
      if (lastByte != -1) {
        in.skip(lastByte);
      }
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e) {
      }
      continue;
    }
    if (numTries == MAX_NUM_RETRIES) {
      throw new IOException("String_Node_Str");
    }
    in.close();
    in=con.openInputStream();
    int len=(int)con.getLength();
    if (len > 0) {
      int actual=0;
      int bytesread=0;
      byte[] data=new byte[len];
      while ((bytesread != len) && (actual != -1)) {
        actual=in.read(data,bytesread,len - bytesread);
        bytesread+=actual;
      }
      process(data);
    }
 else {
      int ch;
      while ((ch=in.read()) != -1) {
        process((byte)ch);
      }
    }
    break;
  }
}