Program: 69716
Project: 69716
Buggy source:
@Test public void testUploadAttachment() throws IOException, URISyntaxException {
  RestConnection conn=new RestConnection();
  assertTrue(conn.login(id1.getName(),"String_Node_Str"));
  URI uri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).queryParam("String_Node_Str",id1.getKey()).queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").build();
  HttpPut method=conn.createPut(uri,MediaType.APPLICATION_JSON,true);
  HttpResponse response=conn.execute(method);
  assertEquals(200,response.getStatusLine().getStatusCode());
  MessageVO message=conn.parse(response,MessageVO.class);
  assertNotNull(message);
  URL portraitUrl=CoursesElementsTest.class.getResource("String_Node_Str");
  assertNotNull(portraitUrl);
  File portrait=new File(portraitUrl.toURI());
  URI attachUri=getForumUriBuilder().path("String_Node_Str").path(message.getKey().toString()).path("String_Node_Str").build();
  HttpPost attachMethod=conn.createPost(attachUri,MediaType.APPLICATION_JSON,true);
  conn.addMultipart(attachMethod,"String_Node_Str",portrait);
  HttpResponse attachResponse=conn.execute(attachMethod);
  assertEquals(200,attachResponse.getStatusLine().getStatusCode());
  ForumManager fm=ForumManager.getInstance();
  VFSContainer container=fm.getMessageContainer(message.getForumKey(),message.getKey());
  VFSItem uploadedFile=container.resolve("String_Node_Str");
  assertNotNull(uploadedFile);
  assertTrue(uploadedFile instanceof VFSLeaf);
  VFSLeaf uploadedImage=(VFSLeaf)uploadedFile;
  InputStream uploadedStream=uploadedImage.getInputStream();
  BufferedImage image=ImageIO.read(uploadedStream);
  FileUtils.closeSafely(uploadedStream);
  assertNotNull(image);
  conn.shutdown();
}

Fixed version (ground truth):
@Test public void testUploadAttachment() throws IOException, URISyntaxException {
  RestConnection conn=new RestConnection();
  assertTrue(conn.login(id1.getName(),"String_Node_Str"));
  URI uri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).queryParam("String_Node_Str",id1.getKey()).queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").build();
  HttpPut method=conn.createPut(uri,MediaType.APPLICATION_JSON,true);
  HttpResponse response=conn.execute(method);
  assertEquals(200,response.getStatusLine().getStatusCode());
  MessageVO message=conn.parse(response,MessageVO.class);
  assertNotNull(message);
  URL portraitUrl=CoursesElementsTest.class.getResource("String_Node_Str");
  assertNotNull(portraitUrl);
  File portrait=new File(portraitUrl.toURI());
  URI attachUri=getForumUriBuilder().path("String_Node_Str").path(message.getKey().toString()).path("String_Node_Str").build();
  HttpPost attachMethod=conn.createPost(attachUri,MediaType.APPLICATION_JSON);
  conn.addMultipart(attachMethod,"String_Node_Str",portrait);
  HttpResponse attachResponse=conn.execute(attachMethod);
  assertEquals(200,attachResponse.getStatusLine().getStatusCode());
  ForumManager fm=ForumManager.getInstance();
  VFSContainer container=fm.getMessageContainer(message.getForumKey(),message.getKey());
  VFSItem uploadedFile=container.resolve("String_Node_Str");
  assertNotNull(uploadedFile);
  assertTrue(uploadedFile instanceof VFSLeaf);
  VFSLeaf uploadedImage=(VFSLeaf)uploadedFile;
  InputStream uploadedStream=uploadedImage.getInputStream();
  BufferedImage image=ImageIO.read(uploadedStream);
  FileUtils.closeSafely(uploadedStream);
  assertNotNull(image);
  conn.shutdown();
}