Program: 43894
Project: 43894
Buggy source:
public File readFile(String remoteFNM,String localFNM) throws Exception {
  File file=null;
  BufferedWriter bw=null;
  DefaultHttpClient httpclient=new DefaultHttpClient();
  httpclient.getCredentialsProvider().setCredentials(new AuthScope(endpoint.getHost(),endpoint.getPort()),creds);
  HttpGet httpget=new HttpGet(endpoint + remoteFNM);
  httpget.setHeader("String_Node_Str",CDMIContentType.CDMI_DATA);
  httpget.setHeader("String_Node_Str",CDMIContentType.CDMI_OBJECT);
  httpget.setHeader("String_Node_Str",CDMIContentType.CDMI_SPEC_VERSION);
  HttpResponse response=httpclient.execute(httpget);
  int responseCode=response.getStatusLine().getStatusCode();
switch (responseCode) {
case 200:
    break;
case 302:
  throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 400:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 401:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 403:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 404:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 406:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
}
InputStream respStream=response.getEntity().getContent();
Gson gson=new Gson();
BlobReadResponse responseBody=gson.fromJson(Utils.convertStreamToString(respStream),BlobReadResponse.class);
if (responseBody.mimetype.equals("String_Node_Str")) {
URL url=new URL(endpoint + remoteFNM);
file=new File(localFNM);
bw=new BufferedWriter(new FileWriter(file));
bw.write(responseBody.value);
bw.close();
}
 else throw new IOException(responseBody.mimetype + "String_Node_Str");
return file;
}

Fixed version (ground truth):
public File readFile(String remoteFNM,String localFNM) throws Exception {
  File file=null;
  BufferedWriter bw=null;
  DefaultHttpClient httpclient=new DefaultHttpClient();
  httpclient.getCredentialsProvider().setCredentials(new AuthScope(endpoint.getHost(),endpoint.getPort()),creds);
  HttpGet httpget=new HttpGet(endpoint + remoteFNM);
  httpget.setHeader("String_Node_Str",CDMIContentType.CDMI_DATA);
  httpget.setHeader("String_Node_Str",CDMIContentType.CDMI_OBJECT);
  httpget.setHeader("String_Node_Str",CDMIContentType.CDMI_SPEC_VERSION);
  HttpResponse response=httpclient.execute(httpget);
  int responseCode=response.getStatusLine().getStatusCode();
switch (responseCode) {
case 200:
    break;
case 302:
  throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 400:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 401:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 403:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 404:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
case 406:
throw new CDMIOperationException("String_Node_Str" + endpoint + remoteFNM,responseCode);
}
InputStream respStream=response.getEntity().getContent();
Gson gson=new Gson();
BlobReadResponse responseBody=gson.fromJson(Utils.convertStreamToString(respStream),BlobReadResponse.class);
HttpEntity ent=response.getEntity();
EntityUtils.consume(ent);
if (responseBody.mimetype.equals("String_Node_Str")) {
URL url=new URL(endpoint + remoteFNM);
file=new File(localFNM);
bw=new BufferedWriter(new FileWriter(file));
bw.write(responseBody.value);
bw.close();
}
 else throw new IOException(responseBody.mimetype + "String_Node_Str");
return file;
}