Program: 69714
Project: 69714
Buggy source:
@Test public void testUpload64Attachment() 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);
  InputStream portraitStream=CoursesElementsTest.class.getResourceAsStream("String_Node_Str");
  assertNotNull(portraitStream);
  URI attachUri=getForumUriBuilder().path("String_Node_Str").path(message.getKey().toString()).path("String_Node_Str").build();
  byte[] portraitBytes=IOUtils.toByteArray(portraitStream);
  byte[] portrait64=Base64.encodeBase64(portraitBytes,true);
  HttpPost attachMethod=conn.createPost(attachUri,MediaType.APPLICATION_JSON,true);
  attachMethod.addHeader("String_Node_Str",MediaType.APPLICATION_FORM_URLENCODED);
  conn.addEntity(attachMethod,new BasicNameValuePair("String_Node_Str",new String(portrait64)),new BasicNameValuePair("String_Node_Str","String_Node_Str"));
  HttpResponse attachCode=conn.execute(attachMethod);
  assertEquals(200,attachCode.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 testUpload64Attachment() 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);
  InputStream portraitStream=CoursesElementsTest.class.getResourceAsStream("String_Node_Str");
  assertNotNull(portraitStream);
  URI attachUri=getForumUriBuilder().path("String_Node_Str").path(message.getKey().toString()).path("String_Node_Str").build();
  byte[] portraitBytes=IOUtils.toByteArray(portraitStream);
  byte[] portrait64=Base64.encodeBase64(portraitBytes,true);
  HttpPost attachMethod=conn.createPost(attachUri,MediaType.APPLICATION_JSON);
  attachMethod.addHeader("String_Node_Str",MediaType.APPLICATION_FORM_URLENCODED);
  conn.addEntity(attachMethod,new BasicNameValuePair("String_Node_Str",new String(portrait64)),new BasicNameValuePair("String_Node_Str","String_Node_Str"));
  HttpResponse attachCode=conn.execute(attachMethod);
  assertEquals(200,attachCode.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();
}