Program: 94351
Project: 94351
Buggy source:
private void doRESTUploadTo(String baseURI,List<BgReading> glucoseDataSets,List<Calibration> meterRecords,List<Calibration> calRecords){
  try {
    int apiVersion=0;
    if (baseURI.endsWith("String_Node_Str"))     apiVersion=1;
    String baseURL=null;
    String secret=null;
    String[] uriParts=baseURI.split("String_Node_Str");
    if (uriParts.length == 1 && apiVersion == 0) {
      baseURL=uriParts[0];
    }
 else     if (uriParts.length == 1 && apiVersion > 0) {
      throw new Exception("String_Node_Str");
    }
 else     if (uriParts.length == 2 && apiVersion > 0) {
      secret=uriParts[0];
      baseURL=uriParts[1];
    }
 else {
      throw new Exception(String.format("String_Node_Str",baseURI,uriParts.length,apiVersion));
    }
    String postURL=baseURL + "String_Node_Str";
    Log.i(TAG,"String_Node_Str" + postURL);
    HttpParams params=new BasicHttpParams();
    HttpConnectionParams.setSoTimeout(params,SOCKET_TIMEOUT);
    HttpConnectionParams.setConnectionTimeout(params,CONNECTION_TIMEOUT);
    DefaultHttpClient httpclient=new DefaultHttpClient(params);
    HttpPost post=new HttpPost(postURL);
    Header apiSecretHeader=null;
    if (apiVersion > 0) {
      if (secret == null || secret.isEmpty()) {
        throw new Exception("String_Node_Str");
      }
 else {
        MessageDigest digest=MessageDigest.getInstance("String_Node_Str");
        byte[] bytes=secret.getBytes("String_Node_Str");
        digest.update(bytes,0,bytes.length);
        bytes=digest.digest();
        StringBuilder sb=new StringBuilder(bytes.length * 2);
        for (        byte b : bytes) {
          sb.append(String.format("String_Node_Str",b & 0xff));
        }
        String token=sb.toString();
        apiSecretHeader=new BasicHeader("String_Node_Str",token);
      }
    }
    if (apiSecretHeader != null) {
      post.setHeader(apiSecretHeader);
    }
    for (    BgReading record : glucoseDataSets) {
      JSONObject json=new JSONObject();
      try {
        if (apiVersion >= 1)         populateV1APIBGEntry(json,record);
 else         populateLegacyAPIEntry(json,record);
      }
 catch (      Exception e) {
        Log.w(TAG,"String_Node_Str" + apiVersion,e);
        continue;
      }
      String jsonString=json.toString();
      Log.i(TAG,"String_Node_Str" + jsonString);
      try {
        StringEntity se=new StringEntity(jsonString);
        post.setEntity(se);
        post.setHeader("String_Node_Str","String_Node_Str");
        post.setHeader("String_Node_Str","String_Node_Str");
        ResponseHandler responseHandler=new BasicResponseHandler();
        httpclient.execute(post,responseHandler);
      }
 catch (      Exception e) {
        Log.w(TAG,"String_Node_Str" + post.getURI().toString() + "String_Node_Str",e);
      }
    }
    if (apiVersion >= 1) {
      for (      Calibration record : meterRecords) {
        JSONObject json=new JSONObject();
        try {
          populateV1APIMeterReadingEntry(json,record);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str" + apiVersion,e);
          continue;
        }
        String jsonString=json.toString();
        Log.i(TAG,"String_Node_Str" + jsonString);
        try {
          StringEntity se=new StringEntity(jsonString);
          post.setEntity(se);
          post.setHeader("String_Node_Str","String_Node_Str");
          post.setHeader("String_Node_Str","String_Node_Str");
          ResponseHandler responseHandler=new BasicResponseHandler();
          httpclient.execute(post,responseHandler);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str" + post.getURI().toString() + "String_Node_Str",e);
        }
      }
    }
    if (apiVersion >= 1) {
      for (      Calibration calRecord : calRecords) {
        JSONObject json=new JSONObject();
        try {
          populateV1APICalibrationEntry(json,calRecord);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str" + apiVersion,e);
          continue;
        }
        String jsonString=json.toString();
        Log.i(TAG,"String_Node_Str" + jsonString);
        try {
          StringEntity se=new StringEntity(jsonString);
          post.setEntity(se);
          post.setHeader("String_Node_Str","String_Node_Str");
          post.setHeader("String_Node_Str","String_Node_Str");
          ResponseHandler responseHandler=new BasicResponseHandler();
          httpclient.execute(post,responseHandler);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str" + post.getURI().toString() + "String_Node_Str",e);
        }
      }
    }
    postDeviceStatus(baseURL,apiSecretHeader,httpclient);
  }
 catch (  Exception e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void doRESTUploadTo(String baseURI,List<BgReading> glucoseDataSets,List<Calibration> meterRecords,List<Calibration> calRecords){
  try {
    int apiVersion=0;
    if (baseURI.endsWith("String_Node_Str"))     apiVersion=1;
    String baseURL=null;
    String secret=null;
    String[] uriParts=baseURI.split("String_Node_Str");
    if (uriParts.length == 1 && apiVersion == 0) {
      baseURL=uriParts[0];
    }
 else     if (uriParts.length == 1 && apiVersion > 0) {
      throw new Exception("String_Node_Str");
    }
 else     if (uriParts.length == 2 && apiVersion > 0) {
      secret=uriParts[0];
      baseURL=uriParts[1];
    }
 else {
      throw new Exception("String_Node_Str");
    }
    String postURL=baseURL + "String_Node_Str";
    Log.i(TAG,"String_Node_Str" + postURL);
    HttpParams params=new BasicHttpParams();
    HttpConnectionParams.setSoTimeout(params,SOCKET_TIMEOUT);
    HttpConnectionParams.setConnectionTimeout(params,CONNECTION_TIMEOUT);
    DefaultHttpClient httpclient=new DefaultHttpClient(params);
    HttpPost post=new HttpPost(postURL);
    Header apiSecretHeader=null;
    if (apiVersion > 0) {
      if (secret == null || secret.isEmpty()) {
        throw new Exception("String_Node_Str");
      }
 else {
        MessageDigest digest=MessageDigest.getInstance("String_Node_Str");
        byte[] bytes=secret.getBytes("String_Node_Str");
        digest.update(bytes,0,bytes.length);
        bytes=digest.digest();
        StringBuilder sb=new StringBuilder(bytes.length * 2);
        for (        byte b : bytes) {
          sb.append(String.format("String_Node_Str",b & 0xff));
        }
        String token=sb.toString();
        apiSecretHeader=new BasicHeader("String_Node_Str",token);
      }
    }
    if (apiSecretHeader != null) {
      post.setHeader(apiSecretHeader);
    }
    for (    BgReading record : glucoseDataSets) {
      JSONObject json=new JSONObject();
      try {
        if (apiVersion >= 1)         populateV1APIBGEntry(json,record);
 else         populateLegacyAPIEntry(json,record);
      }
 catch (      Exception e) {
        Log.w(TAG,"String_Node_Str");
        continue;
      }
      String jsonString=json.toString();
      Log.i(TAG,"String_Node_Str" + jsonString);
      try {
        StringEntity se=new StringEntity(jsonString);
        post.setEntity(se);
        post.setHeader("String_Node_Str","String_Node_Str");
        post.setHeader("String_Node_Str","String_Node_Str");
        ResponseHandler responseHandler=new BasicResponseHandler();
        httpclient.execute(post,responseHandler);
      }
 catch (      Exception e) {
        Log.w(TAG,"String_Node_Str");
      }
    }
    if (apiVersion >= 1) {
      for (      Calibration record : meterRecords) {
        JSONObject json=new JSONObject();
        try {
          populateV1APIMeterReadingEntry(json,record);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str");
          continue;
        }
        String jsonString=json.toString();
        Log.i(TAG,"String_Node_Str" + jsonString);
        try {
          StringEntity se=new StringEntity(jsonString);
          post.setEntity(se);
          post.setHeader("String_Node_Str","String_Node_Str");
          post.setHeader("String_Node_Str","String_Node_Str");
          ResponseHandler responseHandler=new BasicResponseHandler();
          httpclient.execute(post,responseHandler);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str");
        }
      }
    }
    if (apiVersion >= 1) {
      for (      Calibration calRecord : calRecords) {
        JSONObject json=new JSONObject();
        try {
          populateV1APICalibrationEntry(json,calRecord);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str");
          continue;
        }
        String jsonString=json.toString();
        Log.i(TAG,"String_Node_Str" + jsonString);
        try {
          StringEntity se=new StringEntity(jsonString);
          post.setEntity(se);
          post.setHeader("String_Node_Str","String_Node_Str");
          post.setHeader("String_Node_Str","String_Node_Str");
          ResponseHandler responseHandler=new BasicResponseHandler();
          httpclient.execute(post,responseHandler);
        }
 catch (        Exception e) {
          Log.w(TAG,"String_Node_Str");
        }
      }
    }
    postDeviceStatus(baseURL,apiSecretHeader,httpclient);
  }
 catch (  Exception e) {
    Log.w(TAG,"String_Node_Str");
  }
}