Program: 54838
Project: 54838
Buggy source:
@Override public LowLevelHttpResponse execute() throws IOException {
  lowLevelExecCalls++;
  MockLowLevelHttpResponse response=new MockLowLevelHttpResponse();
  String contentRangeHeader=getFirstHeaderValue("String_Node_Str");
  if (testServerError || testIOException) {
switch (lowLevelExecCalls) {
case 3:
      int bytesToRead=maxByteIndexUploadedOnIOException + 1 - bytesUploaded;
    copyBytesToBytesReceivedArray(bytesToRead);
  bytesUploaded+=bytesToRead;
if (testIOException) {
  throw new IOException();
}
response.setStatusCode(500);
return response;
case 4:
if (contentLengthNotSpecified) {
assertEquals("String_Node_Str",contentRangeHeader);
}
 else {
assertEquals("String_Node_Str" + contentLength,contentRangeHeader);
}
response.setStatusCode(contentLength == maxByteIndexUploadedOnIOException + 1 ? 200 : 308);
bytesUploaded=maxByteIndexUploadedOnIOException + 1;
response.addHeader("String_Node_Str","String_Node_Str" + maxByteIndexUploadedOnIOException);
return response;
default :
break;
}
}
 else if (testClientError) {
response.setStatusCode(411);
return response;
}
String bytesRange;
if (bytesUploaded + MediaHttpUploader.DEFAULT_CHUNK_SIZE > contentLength) {
bytesRange=bytesUploaded + "String_Node_Str" + (contentLength - 1);
}
 else {
bytesRange=bytesUploaded + "String_Node_Str" + (bytesUploaded + MediaHttpUploader.DEFAULT_CHUNK_SIZE - 1);
}
String expectedContentRange;
if (contentLength == 0) {
expectedContentRange="String_Node_Str";
}
 else if (contentLengthNotSpecified && ((bytesUploaded + MediaHttpUploader.DEFAULT_CHUNK_SIZE) < contentLength)) {
expectedContentRange="String_Node_Str" + bytesRange + "String_Node_Str";
}
 else {
expectedContentRange="String_Node_Str" + bytesRange + "String_Node_Str"+ contentLength;
}
assertEquals(expectedContentRange,contentRangeHeader);
copyBytesToBytesReceivedArray(-1);
bytesUploaded+=MediaHttpUploader.DEFAULT_CHUNK_SIZE;
if (bytesUploaded >= contentLength) {
response.setStatusCode(200);
}
 else {
response.setStatusCode(308);
response.addHeader("String_Node_Str","String_Node_Str" + bytesRange);
}
return response;
}

Fixed version (ground truth):
@Override public LowLevelHttpResponse execute() throws IOException {
  lowLevelExecCalls++;
  MockLowLevelHttpResponse response=new MockLowLevelHttpResponse();
  String contentRangeHeader=getFirstHeaderValue("String_Node_Str");
  if (testServerError || testIOException) {
switch (lowLevelExecCalls) {
case 3:
      int bytesToRead=maxByteIndexUploadedOnError + 1 - bytesUploaded;
    copyBytesToBytesReceivedArray(bytesToRead);
  bytesUploaded+=bytesToRead;
if (testIOException) {
  throw new IOException();
}
response.setStatusCode(500);
return response;
case 4:
if (contentLengthNotSpecified) {
assertEquals("String_Node_Str",contentRangeHeader);
}
 else {
assertEquals("String_Node_Str" + contentLength,contentRangeHeader);
}
response.setStatusCode(contentLength == maxByteIndexUploadedOnError + 1 ? 200 : 308);
bytesUploaded=maxByteIndexUploadedOnError + 1;
response.addHeader("String_Node_Str","String_Node_Str" + maxByteIndexUploadedOnError);
return response;
default :
break;
}
}
 else if (testClientError) {
response.setStatusCode(411);
return response;
}
String bytesRange;
if (bytesUploaded + MediaHttpUploader.DEFAULT_CHUNK_SIZE > contentLength) {
bytesRange=bytesUploaded + "String_Node_Str" + (contentLength - 1);
}
 else {
bytesRange=bytesUploaded + "String_Node_Str" + (bytesUploaded + MediaHttpUploader.DEFAULT_CHUNK_SIZE - 1);
}
String expectedContentRange;
if (contentLength == 0) {
expectedContentRange="String_Node_Str";
}
 else if (contentLengthNotSpecified && ((bytesUploaded + MediaHttpUploader.DEFAULT_CHUNK_SIZE) < contentLength)) {
expectedContentRange="String_Node_Str" + bytesRange + "String_Node_Str";
}
 else {
expectedContentRange="String_Node_Str" + bytesRange + "String_Node_Str"+ contentLength;
}
assertEquals(expectedContentRange,contentRangeHeader);
copyBytesToBytesReceivedArray(-1);
bytesUploaded+=MediaHttpUploader.DEFAULT_CHUNK_SIZE;
if (bytesUploaded >= contentLength) {
response.setStatusCode(200);
}
 else {
response.setStatusCode(308);
response.addHeader("String_Node_Str","String_Node_Str" + bytesRange);
}
return response;
}