Program: 24239
Project: 24239
Buggy source:
@Test public void testFullSession() throws Exception {
  String path=Paths.get(String.format("String_Node_Str",Paths.get("String_Node_Str").toAbsolutePath().toString(),SCRIPT_PATH,"String_Node_Str")).toString();
  Socket client=new Socket();
  client.connect(new InetSocketAddress("String_Node_Str",61234));
  OutputStream outputStream=client.getOutputStream();
  InputStream inputStream=client.getInputStream();
  byte[] prepare=("String_Node_Str" + "String_Node_Str" + ("String_Node_Str".length() + path.length() + "String_Node_Str".length()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ path+ "String_Node_Str").getBytes("String_Node_Str");
  outputStream.write(prepare);
  outputStream.flush();
  String preparedContent="String_Node_Str" + path + "String_Node_Str";
  ByteBuffer preparedExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + preparedContent.length() + "String_Node_Str"+ "String_Node_Str"+ preparedContent).getBytes("String_Node_Str"));
  ByteBuffer prepared=ByteBuffer.allocate(preparedExpected.capacity());
  while (prepared.hasRemaining()) {
    prepared.put((byte)inputStream.read());
  }
  prepared.flip();
  assertEquals(preparedExpected,prepared);
  byte[] start=("String_Node_Str" + "String_Node_Str" + ("String_Node_Str".length() + path.length() + "String_Node_Str".length()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ path+ "String_Node_Str").getBytes("String_Node_Str");
  outputStream.write(start);
  outputStream.flush();
  String startedContent="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + path + "String_Node_Str";
  ByteBuffer startedExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + startedContent.length() + "String_Node_Str"+ "String_Node_Str"+ startedContent).getBytes("String_Node_Str"));
  ByteBuffer started=ByteBuffer.allocate(startedExpected.capacity());
  while (started.hasRemaining()) {
    started.put((byte)inputStream.read());
  }
  started.flip();
  assertEquals(startedExpected,started);
  byte[] resultRequest=("String_Node_Str" + "String_Node_Str" + ("String_Node_Str".length() + path.length() + "String_Node_Str".length()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ path+ "String_Node_Str").getBytes("String_Node_Str");
  outputStream.write(resultRequest);
  outputStream.flush();
  String finishedContent="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + path + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  ByteBuffer finishedExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + finishedContent.length() + "String_Node_Str"+ "String_Node_Str"+ finishedContent).getBytes("String_Node_Str"));
  String errorContent="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + path + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  ByteBuffer errorExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + errorContent.length() + "String_Node_Str"+ "String_Node_Str"+ errorContent).getBytes("String_Node_Str"));
  ByteBuffer finished=ByteBuffer.allocate(errorExpected.capacity());
  while (finished.hasRemaining()) {
    finished.put((byte)inputStream.read());
    if (!finished.hasRemaining() && finished.capacity() == errorExpected.capacity()) {
      if (inputStream.available() > 0) {
        ByteBuffer temp=ByteBuffer.allocate(finishedExpected.capacity());
        finished.flip();
        temp.put(finished);
        finished=temp;
      }
 else {
        finished.flip();
        assertEquals(errorExpected,finished);
        Thread.sleep(200);
        finished=ByteBuffer.allocate(errorExpected.capacity());
        outputStream.write(resultRequest);
        outputStream.flush();
      }
    }
  }
  finished.flip();
  client.close();
  assertEquals(finishedExpected,finished);
}

Fixed version (ground truth):
@Test(timeout=TEST_TIMEOUT) public void testFullSession() throws Exception {
  String path=Paths.get(String.format("String_Node_Str",Paths.get("String_Node_Str").toAbsolutePath().toString(),SCRIPT_PATH,"String_Node_Str")).toString();
  Socket client=new Socket();
  client.connect(new InetSocketAddress("String_Node_Str",61234));
  OutputStream outputStream=client.getOutputStream();
  InputStream inputStream=client.getInputStream();
  byte[] prepare=("String_Node_Str" + "String_Node_Str" + ("String_Node_Str".length() + path.length()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ path+ "String_Node_Str").getBytes("String_Node_Str");
  outputStream.write(prepare);
  outputStream.flush();
  String preparedContent="String_Node_Str" + path + "String_Node_Str";
  ByteBuffer preparedExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + preparedContent.length() + "String_Node_Str"+ "String_Node_Str"+ preparedContent).getBytes("String_Node_Str"));
  ByteBuffer prepared=ByteBuffer.allocate(preparedExpected.capacity());
  while (prepared.hasRemaining()) {
    prepared.put((byte)inputStream.read());
  }
  prepared.flip();
  assertEquals(preparedExpected,prepared);
  byte[] start=("String_Node_Str" + "String_Node_Str" + ("String_Node_Str".length() + path.length()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ path+ "String_Node_Str").getBytes("String_Node_Str");
  outputStream.write(start);
  outputStream.flush();
  String startedContent="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + path + "String_Node_Str";
  ByteBuffer startedExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + startedContent.length() + "String_Node_Str"+ "String_Node_Str"+ startedContent).getBytes("String_Node_Str"));
  ByteBuffer started=ByteBuffer.allocate(startedExpected.capacity());
  while (started.hasRemaining()) {
    started.put((byte)inputStream.read());
  }
  started.flip();
  assertEquals(startedExpected,started);
  byte[] resultRequest=("String_Node_Str" + "String_Node_Str" + ("String_Node_Str".length() + path.length()) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ path+ "String_Node_Str").getBytes("String_Node_Str");
  outputStream.write(resultRequest);
  outputStream.flush();
  String finishedContent="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + path + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  ByteBuffer finishedExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + finishedContent.length() + "String_Node_Str"+ "String_Node_Str"+ finishedContent).getBytes("String_Node_Str"));
  String errorContent="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + path + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  ByteBuffer errorExpected=ByteBuffer.wrap(("String_Node_Str" + "String_Node_Str" + "String_Node_Str" + errorContent.length() + "String_Node_Str"+ "String_Node_Str"+ errorContent).getBytes("String_Node_Str"));
  ByteBuffer finished=ByteBuffer.allocate(errorExpected.capacity());
  while (finished.hasRemaining()) {
    finished.put((byte)inputStream.read());
    if (!finished.hasRemaining() && finished.capacity() == errorExpected.capacity()) {
      if (inputStream.available() > 0) {
        ByteBuffer temp=ByteBuffer.allocate(finishedExpected.capacity());
        finished.flip();
        temp.put(finished);
        finished=temp;
      }
 else {
        finished.flip();
        assertEquals(errorExpected,finished);
        Thread.sleep(200);
        finished=ByteBuffer.allocate(errorExpected.capacity());
        outputStream.write(resultRequest);
        outputStream.flush();
      }
    }
  }
  finished.flip();
  client.close();
  assertEquals(finishedExpected,finished);
}