Program: 54830
Project: 54830
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=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;
}

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 || (2 * MediaHttpUploader.DEFAULT_CHUNK_SIZE >= contentLength)) {
assertEquals("String_Node_Str" + contentLength,contentRangeHeader);
}
 else {
assertEquals("String_Node_Str",contentRangeHeader);
}
int statusCode=200;
if (contentLength != (maxByteIndexUploadedOnError + 1) || force308OnRangeQueryResponse) {
statusCode=308;
}
response.setStatusCode(statusCode);
response.addHeader("String_Node_Str","String_Node_Str" + maxByteIndexUploadedOnError);
return response;
case 5:
if (force308OnRangeQueryResponse && (contentLength == (maxByteIndexUploadedOnError + 1))) {
assertEquals("String_Node_Str" + contentLength,contentRangeHeader);
response.setStatusCode(200);
response.addHeader("String_Node_Str","String_Node_Str" + contentLength);
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;
}