Program: 4221
Project: 4221
Buggy source:
private void send(OutputStream out,int start,int stop) throws IOException {
  LOG.debug("String_Node_Str" + start + "String_Node_Str"+ stop);
  totalAmountToUpload+=stop - start;
  long t0=System.currentTimeMillis();
  if (minPollTime > 0)   Assert.that(t0 > minPollTime,"String_Node_Str" + (minPollTime - t0) + "String_Node_Str");
  if (maxPollTime > 0)   Assert.that(t0 < maxPollTime,"String_Node_Str" + (t0 - maxPollTime) + "String_Node_Str");
  String httpValue=respondWithHTTP11 ? "String_Node_Str" : "String_Node_Str";
  String str=httpValue + "String_Node_Str" + (busy || queue || partial == 1 ? "String_Node_Str" : "String_Node_Str");
  out.write(str.getBytes());
  if (busy && retryAfter != -1) {
    str="String_Node_Str" + retryAfter + "String_Node_Str";
    out.write(str.getBytes());
  }
  if (queue) {
    LOG.debug("String_Node_Str");
    str="String_Node_Str" + queuePos + "String_Node_Str"+ MIN_POLL / 1000 + "String_Node_Str" + MAX_POLL / 1000 + "String_Node_Str";
    out.write(str.getBytes());
    str="String_Node_Str";
    out.write(str.getBytes());
    out.flush();
    long t=System.currentTimeMillis();
    minPollTime=t + MIN_POLL;
    maxPollTime=t + MAX_POLL;
    return;
  }
  if (partial > 0) {
switch (partial) {
case 1:
      str="String_Node_Str";
    break;
case 2:
  str="String_Node_Str";
break;
default :
str="String_Node_Str";
}
out.write(str.getBytes());
out.flush();
partial++;
if (partial == 2) {
str="String_Node_Str";
out.write(str.getBytes());
out.flush();
return;
}
}
if (sendContentLength) {
str="String_Node_Str" + (stop - start) + "String_Node_Str";
out.write(str.getBytes());
}
if (start != 0 || (stop - start != TestFile.length())) {
str="String_Node_Str" + start + "String_Node_Str"+ (stop - 1)+ "String_Node_Str"+ TestFile.length()+ "String_Node_Str";
out.write(str.getBytes());
}
if (storedGoodLocs != null && storedGoodLocs.hasAlternateLocations()) {
LOG.debug("String_Node_Str" + storedGoodLocs + "String_Node_Str");
HTTPUtils.writeHeader(HTTPHeaderName.ALT_LOCATION,storedGoodLocs,out);
}
 else {
LOG.debug("String_Node_Str" + storedGoodLocs + "String_Node_Str");
}
if (storedBadLocs != null && storedBadLocs.hasAlternateLocations()) {
LOG.debug("String_Node_Str" + storedBadLocs + "String_Node_Str");
HTTPUtils.writeHeader(HTTPHeaderName.NALTS,storedBadLocs,out);
}
 else {
LOG.debug("String_Node_Str" + storedBadLocs + "String_Node_Str");
}
if (creationTime != null) {
LOG.debug("String_Node_Str");
HTTPUtils.writeHeader(HTTPHeaderName.CREATION_TIME,"String_Node_Str" + creationTime,out);
}
if (sendThexTreeHeader) {
HTTPUtils.writeHeader(HTTPHeaderName.THEX_URI,TestFile.tree(),out);
}
if (interestedInFalts) {
if (!isFirewalled) HTTPUtils.writeFeatures(out);
 else {
boolean previous=RouterService.acceptedIncomingConnection();
try {
PrivilegedAccessor.setValue(RouterService.getAcceptor(),"String_Node_Str",new Boolean(false));
HTTPUtils.writeFeatures(out);
PrivilegedAccessor.setValue(RouterService.getAcceptor(),"String_Node_Str",new Boolean(previous));
}
 catch (Exception bad) {
ErrorService.error(bad);
}
}
}
if (isFirewalled && _proxiesString != null) {
HTTPUtils.writeHeader(HTTPHeaderName.PROXIES,_proxiesString,out);
}
out.flush();
if (stallHeaders) {
LOG.debug("String_Node_Str");
try {
Thread.sleep(100000000);
}
 catch (InterruptedException end) {
return;
}
}
str="String_Node_Str";
out.write(str.getBytes());
out.flush();
if (busy) {
if (connects >= timesBusy) busy=false;
out.close();
return;
}
int length=stop - start;
int okLength=length - (int)(length * corruptPercentage);
amountThisRequest=0;
boolean sentCorrupt=false;
for (int i=start; i < stop; ) {
if (stopAfter > -1) {
Assert.that(fullRequestsUploaded + amountThisRequest <= stopAfter,"String_Node_Str" + fullRequestsUploaded + "String_Node_Str"+ amountThisRequest+ "String_Node_Str"+ stopAfter);
if (fullRequestsUploaded + amountThisRequest == stopAfter) {
stopped=true;
out.flush();
LOG.debug(name + "String_Node_Str" + (fullRequestsUploaded + amountThisRequest));
throw new IOException();
}
}
throttle.request(1);
if (sendCorrupt && (i - start) >= okLength) {
sentCorrupt=true;
out.write(TestFile.getByte(i) + (byte)1);
}
 else out.write(TestFile.getByte(i));
amountThisRequest++;
i++;
}
if (sentCorrupt) LOG.debug("String_Node_Str");
out.flush();
fullRequestsUploaded+=amountThisRequest;
amountThisRequest=0;
}

Fixed version (ground truth):
private void send(OutputStream out,int start,int stop) throws IOException {
  LOG.debug("String_Node_Str" + start + "String_Node_Str"+ stop);
  totalAmountToUpload+=stop - start;
  long t0=System.currentTimeMillis();
  if (minPollTime > 0)   Assert.that(t0 > minPollTime,"String_Node_Str" + (minPollTime - t0) + "String_Node_Str");
  if (maxPollTime > 0)   Assert.that(t0 < maxPollTime,"String_Node_Str" + (t0 - maxPollTime) + "String_Node_Str");
  String httpValue=respondWithHTTP11 ? "String_Node_Str" : "String_Node_Str";
  String str=httpValue + "String_Node_Str" + (busy || queue || partial == 1 ? "String_Node_Str" : "String_Node_Str");
  out.write(str.getBytes());
  if (busy && retryAfter != -1) {
    str="String_Node_Str" + retryAfter + "String_Node_Str";
    out.write(str.getBytes());
  }
  if (queue) {
    LOG.debug("String_Node_Str");
    str="String_Node_Str" + queuePos + "String_Node_Str"+ MIN_POLL / 1000 + "String_Node_Str" + MAX_POLL / 1000 + "String_Node_Str";
    out.write(str.getBytes());
    str="String_Node_Str";
    out.write(str.getBytes());
    out.flush();
    long t=System.currentTimeMillis();
    minPollTime=t + MIN_POLL;
    maxPollTime=t + MAX_POLL;
    return;
  }
  if (partial > 0) {
switch (partial) {
case 1:
      str="String_Node_Str";
    break;
case 2:
  str="String_Node_Str";
break;
default :
str="String_Node_Str";
}
out.write(str.getBytes());
out.flush();
partial++;
if (partial == 2) {
str="String_Node_Str";
out.write(str.getBytes());
out.flush();
return;
}
}
if (sendContentLength) {
str="String_Node_Str" + (stop - start) + "String_Node_Str";
out.write(str.getBytes());
}
if (start != 0 || (stop - start != TestFile.length())) {
str="String_Node_Str" + start + "String_Node_Str"+ (stop - 1)+ "String_Node_Str"+ TestFile.length()+ "String_Node_Str";
out.write(str.getBytes());
}
if (storedGoodLocs != null && storedGoodLocs.hasAlternateLocations()) {
LOG.debug("String_Node_Str" + storedGoodLocs + "String_Node_Str");
HTTPUtils.writeHeader(HTTPHeaderName.ALT_LOCATION,storedGoodLocs,out);
}
 else {
LOG.debug("String_Node_Str" + storedGoodLocs + "String_Node_Str");
}
if (storedBadLocs != null && storedBadLocs.hasAlternateLocations()) {
LOG.debug("String_Node_Str" + storedBadLocs + "String_Node_Str");
HTTPUtils.writeHeader(HTTPHeaderName.NALTS,storedBadLocs,out);
}
 else {
LOG.debug("String_Node_Str" + storedBadLocs + "String_Node_Str");
}
if (creationTime != null) {
LOG.debug("String_Node_Str");
HTTPUtils.writeHeader(HTTPHeaderName.CREATION_TIME,"String_Node_Str" + creationTime,out);
}
if (sendThexTreeHeader) {
HTTPUtils.writeHeader(HTTPHeaderName.THEX_URI,TestFile.tree(),out);
}
if (interestedInFalts) {
if (!isFirewalled) HTTPUtils.writeFeatures(out);
 else {
boolean previous=RouterService.acceptedIncomingConnection();
try {
PrivilegedAccessor.setValue(RouterService.getAcceptor(),"String_Node_Str",new Boolean(false));
HTTPUtils.writeFeatures(out);
PrivilegedAccessor.setValue(RouterService.getAcceptor(),"String_Node_Str",new Boolean(previous));
}
 catch (Exception bad) {
ErrorService.error(bad);
}
}
}
if (isFirewalled && _proxiesString != null) {
HTTPUtils.writeHeader(HTTPHeaderName.PROXIES,_proxiesString,out);
}
out.flush();
if (stallHeaders) {
LOG.debug("String_Node_Str");
try {
Thread.sleep(100000000);
}
 catch (InterruptedException end) {
return;
}
}
str="String_Node_Str";
out.write(str.getBytes());
out.flush();
if (busy) {
if (connects >= timesBusy) busy=false;
out.close();
return;
}
int length=stop - start;
int okLength=length - (int)(length * corruptPercentage);
amountThisRequest=0;
boolean sentCorrupt=false;
for (int i=start; i < stop; ) {
if (stopAfter > -1) {
Assert.that(fullRequestsUploaded + amountThisRequest <= stopAfter,"String_Node_Str" + fullRequestsUploaded + "String_Node_Str"+ amountThisRequest+ "String_Node_Str"+ stopAfter);
if (fullRequestsUploaded + amountThisRequest == stopAfter) {
stopped=true;
synchronized (stoppedLock) {
stoppedLock.notifyAll();
}
out.flush();
LOG.debug(name + "String_Node_Str" + (fullRequestsUploaded + amountThisRequest));
throw new IOException();
}
}
throttle.request(1);
if (sendCorrupt && (i - start) >= okLength) {
sentCorrupt=true;
out.write(TestFile.getByte(i) + (byte)1);
}
 else out.write(TestFile.getByte(i));
amountThisRequest++;
i++;
}
if (sentCorrupt) LOG.debug("String_Node_Str");
out.flush();
fullRequestsUploaded+=amountThisRequest;
amountThisRequest=0;
}