nus-yam/ex-repair huggingface dataset:
Program: 98
Project: 98
Buggy source:
public RequestImpl(Request prototype){
  if (prototype != null) {
    this.method=prototype.getMethod();
    int pos=prototype.getUrl().indexOf("String_Node_Str");
    this.url=pos > 0 ? prototype.getUrl().substring(0,pos) : prototype.getUrl();
    this.headers=new FluentCaseInsensitiveStringsMap(prototype.getHeaders());
    this.cookies=new ArrayList<Cookie>(prototype.getCookies());
    this.byteData=prototype.getByteData();
    this.stringData=prototype.getStringData();
    this.streamData=prototype.getStreamData();
    this.entityWriter=prototype.getEntityWriter();
    this.bodyGenerator=prototype.getBodyGenerator();
    this.params=(prototype.getParams() == null ? null : new FluentStringsMap(prototype.getParams()));
    this.queryParams=(prototype.getQueryParams() == null ? null : new FluentStringsMap(prototype.getQueryParams()));
    this.parts=(prototype.getParts() == null ? null : new ArrayList<Part>(prototype.getParts()));
    this.virtualHost=prototype.getVirtualHost();
    this.length=prototype.getContentLength();
    this.proxyServer=prototype.getProxyServer();
    this.realm=prototype.getRealm();
    this.file=prototype.getFile();
    this.followRedirects=prototype.isRedirectEnabled();
    this.perRequestConfig=prototype.getPerRequestConfig();
    this.rangeOffset=prototype.getRangeOffset();
    this.charset=prototype.getBodyEncoding();
  }
}

Fixed version (ground truth):
public RequestImpl(Request prototype){
  if (prototype != null) {
    this.method=prototype.getMethod();
    int pos=prototype.getUrl().indexOf("String_Node_Str");
    this.url=pos > 0 ? prototype.getUrl().substring(0,pos) : prototype.getUrl();
    this.headers=new FluentCaseInsensitiveStringsMap(prototype.getHeaders());
    this.cookies=new ArrayList<Cookie>(prototype.getCookies());
    this.byteData=prototype.getByteData();
    this.stringData=prototype.getStringData();
    this.streamData=prototype.getStreamData();
    this.entityWriter=prototype.getEntityWriter();
    this.bodyGenerator=prototype.getBodyGenerator();
    this.params=(prototype.getParams() == null ? null : new FluentStringsMap(prototype.getParams()));
    this.queryParams=(prototype.getQueryParams() == null ? null : new FluentStringsMap(prototype.getQueryParams()));
    this.parts=(prototype.getParts() == null ? null : new ArrayList<Part>(prototype.getParts()));
    this.virtualHost=prototype.getVirtualHost();
    this.length=prototype.getContentLength();
    this.proxyServer=prototype.getProxyServer();
    this.realm=prototype.getRealm();
    this.file=prototype.getFile();
    this.followRedirects=prototype.isRedirectEnabled();
    this.perRequestConfig=prototype.getPerRequestConfig();
    this.rangeOffset=prototype.getRangeOffset();
    this.charset=prototype.getBodyEncoding();
    this.useRawUrl=prototype.isUseRawUrl();
  }
}
Program: 99
Project: 99
Buggy source:
public long transferTo(long position,long count,WritableByteChannel target) throws IOException {
  long overallLength=0;
  if (_startPart == _parts.size()) {
    return overallLength;
  }
  long availableLength=count;
  int tempPart=_startPart;
  long totalLength=0;
  boolean full=false;
  while (!full && tempPart < _parts.size()) {
    Part currentPart=(Part)_parts.get(tempPart);
    currentPart.setPartBoundary(_boundary);
    long length=currentPart.length();
    if ((length + totalLength) < availableLength) {
      totalLength+=length;
      tempPart++;
      if (currentPart.getClass().equals(StringPart.class)) {
        ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
        Part.sendPart(outputStream,currentPart,_boundary);
        overallLength+=writeToTarget(target,outputStream);
      }
 else       if (currentPart.getClass().equals(FilePart.class)) {
        FilePart filePart=(FilePart)currentPart;
        ByteArrayOutputStream overhead=new ByteArrayOutputStream();
        filePart.setPartBoundary(_boundary);
        filePart.sendStart(overhead);
        filePart.sendDispositionHeader(overhead);
        filePart.sendContentTypeHeader(overhead);
        filePart.sendTransferEncodingHeader(overhead);
        filePart.sendEndOfHeader(overhead);
        overallLength+=writeToTarget(target,overhead);
        FilePartSource source=(FilePartSource)filePart.getSource();
        File file=source.getFile();
        RandomAccessFile raf=new RandomAccessFile(file,"String_Node_Str");
        _files.add(raf);
        FileChannel fc=raf.getChannel();
        long fileLength=fc.transferTo(0,file.length(),target);
        if (fileLength != file.length()) {
          System.out.println("String_Node_Str");
        }
        ByteArrayOutputStream endOverhead=new ByteArrayOutputStream();
        filePart.sendEnd(endOverhead);
        overallLength+=this.writeToTarget(target,endOverhead);
      }
    }
 else {
      full=true;
    }
  }
  ByteArrayOutputStream endWriter=new ByteArrayOutputStream();
  Part.sendMessageEnd(endWriter,_boundary);
  overallLength+=writeToTarget(target,endWriter);
  _startPart=tempPart;
  return overallLength;
}

Fixed version (ground truth):
public long transferTo(long position,long count,WritableByteChannel target) throws IOException {
  long overallLength=0;
  if (_startPart == _parts.size()) {
    return overallLength;
  }
  int tempPart=_startPart;
  for (  com.ning.http.client.Part part : _parts) {
    if (part instanceof Part) {
      overallLength+=handleMultiPart(target,(Part)part);
    }
 else {
      overallLength+=handleClientPart(target,part);
    }
    tempPart++;
  }
  ByteArrayOutputStream endWriter=new ByteArrayOutputStream();
  Part.sendMessageEnd(endWriter,_boundary);
  overallLength+=writeToTarget(target,endWriter);
  _startPart=tempPart;
  return overallLength;
}
Program: 100
Project: 100
Buggy source:
public void setUpServer(String auth) throws Exception {
  server=new Server();
  Logger root=Logger.getRootLogger();
  root.setLevel(Level.DEBUG);
  root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
  port1=findFreePort();
  Connector listener=new SelectChannelConnector();
  listener.setHost("String_Node_Str");
  listener.setPort(port1);
  server.addConnector(listener);
  LoginService loginService=new HashLoginService("String_Node_Str","String_Node_Str");
  server.addBean(loginService);
  Constraint constraint=new Constraint();
  constraint.setName(auth);
  constraint.setRoles(new String[]{user,admin});
  constraint.setAuthenticate(true);
  ConstraintMapping mapping=new ConstraintMapping();
  mapping.setConstraint(constraint);
  mapping.setPathSpec("String_Node_Str");
  Set<String> knownRoles=new HashSet<String>();
  knownRoles.add(user);
  knownRoles.add(admin);
  ConstraintSecurityHandler security=new ConstraintSecurityHandler();
  security.setConstraintMappings(new ConstraintMapping[]{mapping},knownRoles);
  security.setAuthenticator(new BasicAuthenticator());
  security.setLoginService(loginService);
  security.setStrict(false);
  security.setHandler(configureHandler());
  server.setHandler(security);
  server.start();
  log.info("String_Node_Str");
}

Fixed version (ground truth):
public void setUpServer(String auth) throws Exception {
  server=new Server();
  Logger root=Logger.getRootLogger();
  root.setLevel(Level.DEBUG);
  root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
  port1=findFreePort();
  Connector listener=new SelectChannelConnector();
  listener.setHost("String_Node_Str");
  listener.setPort(port1);
  server.addConnector(listener);
  LoginService loginService=new HashLoginService("String_Node_Str","String_Node_Str");
  server.addBean(loginService);
  Constraint constraint=new Constraint();
  constraint.setName(auth);
  constraint.setRoles(new String[]{user,admin});
  constraint.setAuthenticate(true);
  ConstraintMapping mapping=new ConstraintMapping();
  mapping.setConstraint(constraint);
  mapping.setPathSpec("String_Node_Str");
  Set<String> knownRoles=new HashSet<String>();
  knownRoles.add(user);
  knownRoles.add(admin);
  ConstraintSecurityHandler security=new ConstraintSecurityHandler();
  security.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{mapping}),knownRoles);
  security.setAuthenticator(new BasicAuthenticator());
  security.setLoginService(loginService);
  security.setStrict(false);
  security.setHandler(configureHandler());
  server.setHandler(security);
  server.start();
  log.info("String_Node_Str");
}
Program: 101
Project: 101
Buggy source:
@BeforeClass(alwaysRun=true) @Override public void setUpGlobal() throws Exception {
  server=new Server();
  Logger root=Logger.getRootLogger();
  root.setLevel(Level.DEBUG);
  root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
  port1=findFreePort();
  Connector listener=new SelectChannelConnector();
  listener.setHost("String_Node_Str");
  listener.setPort(port1);
  server.addConnector(listener);
  LoginService loginService=new HashLoginService("String_Node_Str","String_Node_Str");
  server.addBean(loginService);
  Constraint constraint=new Constraint();
  constraint.setName(Constraint.__BASIC_AUTH);
  constraint.setRoles(new String[]{user,admin});
  constraint.setAuthenticate(true);
  ConstraintMapping mapping=new ConstraintMapping();
  mapping.setConstraint(constraint);
  mapping.setPathSpec("String_Node_Str");
  Set<String> knownRoles=new HashSet<String>();
  knownRoles.add(user);
  knownRoles.add(admin);
  ConstraintSecurityHandler security=new ConstraintSecurityHandler();
  security.setConstraintMappings(new ConstraintMapping[]{mapping},knownRoles);
  security.setAuthenticator(new BasicAuthenticator());
  security.setLoginService(loginService);
  security.setStrict(false);
  security.setHandler(configureHandler());
  server.setHandler(security);
  server.start();
  log.info("String_Node_Str");
}

Fixed version (ground truth):
@BeforeClass(alwaysRun=true) @Override public void setUpGlobal() throws Exception {
  server=new Server();
  Logger root=Logger.getRootLogger();
  root.setLevel(Level.DEBUG);
  root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
  port1=findFreePort();
  Connector listener=new SelectChannelConnector();
  listener.setHost("String_Node_Str");
  listener.setPort(port1);
  server.addConnector(listener);
  LoginService loginService=new HashLoginService("String_Node_Str","String_Node_Str");
  server.addBean(loginService);
  Constraint constraint=new Constraint();
  constraint.setName(Constraint.__BASIC_AUTH);
  constraint.setRoles(new String[]{user,admin});
  constraint.setAuthenticate(true);
  ConstraintMapping mapping=new ConstraintMapping();
  mapping.setConstraint(constraint);
  mapping.setPathSpec("String_Node_Str");
  Set<String> knownRoles=new HashSet<String>();
  knownRoles.add(user);
  knownRoles.add(admin);
  ConstraintSecurityHandler security=new ConstraintSecurityHandler();
  security.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{mapping}),knownRoles);
  security.setAuthenticator(new BasicAuthenticator());
  security.setLoginService(loginService);
  security.setStrict(false);
  security.setHandler(configureHandler());
  server.setHandler(security);
  server.start();
  log.info("String_Node_Str");
}
Program: 103
Project: 103
Buggy source:
@BeforeClass(alwaysRun=true) @Override public void setUpGlobal() throws Exception {
  server=new Server();
  Logger root=Logger.getRootLogger();
  root.setLevel(Level.DEBUG);
  root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
  port1=findFreePort();
  Connector listener=new SelectChannelConnector();
  listener.setHost("String_Node_Str");
  listener.setPort(port1);
  server.addConnector(listener);
  LoginService loginService=new HashLoginService("String_Node_Str","String_Node_Str");
  server.addBean(loginService);
  Constraint constraint=new Constraint();
  constraint.setName(Constraint.__BASIC_AUTH);
  constraint.setRoles(new String[]{user,admin});
  constraint.setAuthenticate(true);
  ConstraintMapping mapping=new ConstraintMapping();
  mapping.setConstraint(constraint);
  mapping.setPathSpec("String_Node_Str");
  Set<String> knownRoles=new HashSet<String>();
  knownRoles.add(user);
  knownRoles.add(admin);
  ConstraintSecurityHandler security=new ConstraintSecurityHandler();
  security.setConstraintMappings(new ConstraintMapping[]{mapping},knownRoles);
  security.setAuthenticator(new DigestAuthenticator());
  security.setLoginService(loginService);
  security.setStrict(false);
  security.setHandler(configureHandler());
  server.setHandler(security);
  server.start();
  log.info("String_Node_Str");
}

Fixed version (ground truth):
@BeforeClass(alwaysRun=true) @Override public void setUpGlobal() throws Exception {
  server=new Server();
  Logger root=Logger.getRootLogger();
  root.setLevel(Level.DEBUG);
  root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
  port1=findFreePort();
  Connector listener=new SelectChannelConnector();
  listener.setHost("String_Node_Str");
  listener.setPort(port1);
  server.addConnector(listener);
  LoginService loginService=new HashLoginService("String_Node_Str","String_Node_Str");
  server.addBean(loginService);
  Constraint constraint=new Constraint();
  constraint.setName(Constraint.__BASIC_AUTH);
  constraint.setRoles(new String[]{user,admin});
  constraint.setAuthenticate(true);
  ConstraintMapping mapping=new ConstraintMapping();
  mapping.setConstraint(constraint);
  mapping.setPathSpec("String_Node_Str");
  Set<String> knownRoles=new HashSet<String>();
  knownRoles.add(user);
  knownRoles.add(admin);
  ConstraintSecurityHandler security=new ConstraintSecurityHandler();
  security.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{mapping}),knownRoles);
  security.setAuthenticator(new DigestAuthenticator());
  security.setLoginService(loginService);
  security.setStrict(false);
  security.setHandler(configureHandler());
  server.setHandler(security);
  server.start();
  log.info("String_Node_Str");
}
Program: 104
Project: 104
Buggy source:
public final void operationComplete(ChannelFuture f) throws Exception {
  if (f.isSuccess()) {
    if (!handshakeDone.getAndSet(true) && f.getChannel().getPipeline().get(NettyAsyncHttpProvider.SSL_HANDLER) != null) {
      ((SslHandler)f.getChannel().getPipeline().get(NettyAsyncHttpProvider.SSL_HANDLER)).handshake().addListener(this);
      return;
    }
    f.getChannel().getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(future);
    future.provider().writeRequest(f.getChannel(),config,future,nettyRequest);
  }
 else {
    Throwable cause=f.getCause();
    logger.debug("String_Node_Str",f.getChannel(),future.canRetry());
    if (future.canRetry() && cause != null && (NettyAsyncHttpProvider.abortOnDisconnectException(cause) || ClosedChannelException.class.isAssignableFrom(cause.getClass()) || future.getState() != NettyResponseFuture.STATE.NEW)) {
      logger.debug("String_Node_Str",nettyRequest);
      if (future.provider().remotelyClosed(f.getChannel(),future)) {
        return;
      }
    }
    logger.debug("String_Node_Str",cause,f.getChannel());
    ConnectException e=new ConnectException(f.getCause() != null ? cause.getMessage() : future.getURI().toString());
    if (cause != null) {
      e.initCause(cause);
    }
    future.abort(e);
  }
}

Fixed version (ground truth):
public final void operationComplete(ChannelFuture f) throws Exception {
  if (f.isSuccess()) {
    f.getChannel().getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(future);
    if (!handshakeDone.getAndSet(true) && f.getChannel().getPipeline().get(NettyAsyncHttpProvider.SSL_HANDLER) != null) {
      ((SslHandler)f.getChannel().getPipeline().get(NettyAsyncHttpProvider.SSL_HANDLER)).handshake().addListener(this);
      return;
    }
    future.provider().writeRequest(f.getChannel(),config,future,nettyRequest);
  }
 else {
    Throwable cause=f.getCause();
    logger.debug("String_Node_Str",f.getChannel(),future.canRetry());
    if (future.canRetry() && cause != null && (NettyAsyncHttpProvider.abortOnDisconnectException(cause) || ClosedChannelException.class.isAssignableFrom(cause.getClass()) || future.getState() != NettyResponseFuture.STATE.NEW)) {
      logger.debug("String_Node_Str",nettyRequest);
      if (future.provider().remotelyClosed(f.getChannel(),future)) {
        return;
      }
    }
    logger.debug("String_Node_Str",cause,f.getChannel());
    ConnectException e=new ConnectException(f.getCause() != null ? cause.getMessage() : future.getURI().toString());
    if (cause != null) {
      e.initCause(cause);
    }
    future.abort(e);
  }
}
Program: 105
Project: 105
Buggy source:
@Override public int read() throws IOException {
  if (++bytePos >= active.length) {
    if (++currentPos >= parts.length) {
      return -1;
    }
    bytePos=0;
    active=parts[currentPos].getBodyPartBytes();
  }
  return active[bytePos];
}

Fixed version (ground truth):
@Override public int read() throws IOException {
  if (++bytePos >= active.length) {
    if (++currentPos >= parts.length) {
      return -1;
    }
    bytePos=0;
    active=parts[currentPos].getBodyPartBytes();
  }
  return active[bytePos] & 0xFF;
}
Program: 106
Project: 106
Buggy source:
/** 
 * This method -- unlike Future<Reponse>.get() -- will block only as long, as headers arrive. This is useful for large transfers, to examine headers ASAP, and defer body streaming to it's fine destination and prevent unneeded bandwidth consumption. The response here will contain the very 1st response from server, so status code and headers, but it might be incomplete in case of broken servers sending trailing headers. In that case, the "usual" Future<Response>.get() method will return complete headers, but multiple invocations of getResponse() will always return the 1st cached, probably incomplete one. Note: the response returned by this method will contain everything <em>except</em> the response body itself, so invoking any method like Response.getResponseBodyXXX() will result in error!
 * @return
 * @throws InterruptedException
 */
public Response getResponse() throws InterruptedException {
  headersArrived.await();
  return response;
}

Fixed version (ground truth):
/** 
 * This method -- unlike Future<Reponse>.get() -- will block only as long, as headers arrive. This is useful for large transfers, to examine headers ASAP, and defer body streaming to it's fine destination and prevent unneeded bandwidth consumption. The response here will contain the very 1st response from server, so status code and headers, but it might be incomplete in case of broken servers sending trailing headers. In that case, the "usual" Future<Response>.get() method will return complete headers, but multiple invocations of getResponse() will always return the 1st cached, probably incomplete one. Note: the response returned by this method will contain everything <em>except</em> the response body itself, so invoking any method like Response.getResponseBodyXXX() will result in error! Also, please not that this method might return <code>null</code> in case of some errors.
 * @return
 * @throws InterruptedException
 */
public Response getResponse() throws InterruptedException {
  headersArrived.await();
  return response;
}
Program: 107
Project: 107
Buggy source:
public BodyDeferringInputStream(final Future<T> future,final InputStream in){
  super(in);
  this.future=future;
}

Fixed version (ground truth):
public BodyDeferringInputStream(final Future<Response> future,final BodyDeferringAsyncHandler bdah,final InputStream in){
  super(in);
  this.future=future;
  this.bdah=bdah;
}
Program: 108
Project: 108
Buggy source:
public void close() throws IOException {
  super.close();
  get();
}

Fixed version (ground truth):
/** 
 * Closes the input stream, and "joins" (wait for complete execution together with potential exception thrown) of the async request.
 */
public void close() throws IOException {
  super.close();
  try {
    getLastResponse();
  }
 catch (  Exception e) {
    IOException ioe=new IOException(e.getMessage());
    ioe.initCause(e);
    throw ioe;
  }
}
Program: 109
Project: 109
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredSimpleWithFailure() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str").addHeader("String_Node_Str",Boolean.TRUE.toString());
  CountingOutputStream cos=new CountingOutputStream();
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(cos);
  Future<Response> f=r.execute(bdah);
  Response resp=bdah.getResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  assertEquals(false,HALF_GIG == cos.getByteCount());
  try {
    f.get();
    Assert.fail("String_Node_Str");
  }
 catch (  Exception e) {
  }
  assertEquals(false,HALF_GIG == cos.getByteCount());
  client.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredSimpleWithFailure() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str").addHeader("String_Node_Str",Boolean.TRUE.toString());
  CountingOutputStream cos=new CountingOutputStream();
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(cos);
  Future<Response> f=r.execute(bdah);
  Response resp=bdah.getResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  assertEquals(true,HALF_GIG >= cos.getByteCount());
  try {
    f.get();
    Assert.fail("String_Node_Str");
  }
 catch (  Exception e) {
  }
  assertEquals(false,HALF_GIG == cos.getByteCount());
  client.close();
}
Program: 110
Project: 110
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredInputStreamTrickWithFailure() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str").addHeader("String_Node_Str",Boolean.TRUE.toString());
  PipedOutputStream pos=new PipedOutputStream();
  PipedInputStream pis=new PipedInputStream(pos);
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(pos);
  Future<Response> f=r.execute(bdah);
  InputStream is=new BodyDeferringAsyncHandler.BodyDeferringInputStream<Response>(f,pis);
  Response resp=bdah.getResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  CountingOutputStream cos=new CountingOutputStream();
  try {
    copy(is,cos);
    Assert.fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
  client.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredInputStreamTrickWithFailure() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str").addHeader("String_Node_Str",Boolean.TRUE.toString());
  PipedOutputStream pos=new PipedOutputStream();
  PipedInputStream pis=new PipedInputStream(pos);
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(pos);
  Future<Response> f=r.execute(bdah);
  BodyDeferringInputStream is=new BodyDeferringInputStream(f,bdah,pis);
  Response resp=is.getAsapResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  CountingOutputStream cos=new CountingOutputStream();
  try {
    copy(is,cos);
    Assert.fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
  client.close();
}
Program: 111
Project: 111
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredSimple() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str");
  CountingOutputStream cos=new CountingOutputStream();
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(cos);
  Future<Response> f=r.execute(bdah);
  Response resp=bdah.getResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  assertEquals(false,HALF_GIG == cos.getByteCount());
  f.get();
  assertEquals(true,HALF_GIG == cos.getByteCount());
  client.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredSimple() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str");
  CountingOutputStream cos=new CountingOutputStream();
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(cos);
  Future<Response> f=r.execute(bdah);
  Response resp=bdah.getResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  assertEquals(true,HALF_GIG >= cos.getByteCount());
  f.get();
  assertEquals(true,HALF_GIG == cos.getByteCount());
  client.close();
}
Program: 112
Project: 112
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredInputStreamTrick() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str");
  PipedOutputStream pos=new PipedOutputStream();
  PipedInputStream pis=new PipedInputStream(pos);
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(pos);
  Future<Response> f=r.execute(bdah);
  InputStream is=new BodyDeferringAsyncHandler.BodyDeferringInputStream<Response>(f,pis);
  Response resp=bdah.getResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  CountingOutputStream cos=new CountingOutputStream();
  copy(is,cos);
  assertEquals(true,HALF_GIG == cos.getByteCount());
  client.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str"}) public void deferredInputStreamTrick() throws IOException, ExecutionException, TimeoutException, InterruptedException {
  AsyncHttpClient client=getAsyncHttpClient(getAsyncHttpClientConfig());
  AsyncHttpClient.BoundRequestBuilder r=client.prepareGet("String_Node_Str" + port1 + "String_Node_Str");
  PipedOutputStream pos=new PipedOutputStream();
  PipedInputStream pis=new PipedInputStream(pos);
  BodyDeferringAsyncHandler bdah=new BodyDeferringAsyncHandler(pos);
  Future<Response> f=r.execute(bdah);
  BodyDeferringInputStream is=new BodyDeferringInputStream(f,bdah,pis);
  Response resp=is.getAsapResponse();
  assertNotNull(resp);
  assertEquals(resp.getStatusCode(),HttpServletResponse.SC_OK);
  assertEquals(true,resp.getHeader("String_Node_Str").equals(String.valueOf(HALF_GIG)));
  CountingOutputStream cos=new CountingOutputStream();
  copy(is,cos);
  assertEquals(true,HALF_GIG == cos.getByteCount());
  client.close();
}
Program: 113
Project: 113
Buggy source:
public String getResponseBodyExcerpt(int maxLength,String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=parseCharset(contentType);
  }
  String response=contentToString(charset);
  return response.length() <= maxLength ? response : response.substring(0,maxLength);
}

Fixed version (ground truth):
public String getResponseBodyExcerpt(int maxLength,String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=AsyncHttpProviderUtils.parseCharset(contentType);
  }
  if (charset == null) {
    charset=DEFAULT_CHARSET;
  }
  String response=contentToString(charset);
  return response.length() <= maxLength ? response : response.substring(0,maxLength);
}
Program: 114
Project: 114
Buggy source:
public String getResponseBody(String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=parseCharset(contentType);
  }
  return contentToString(charset);
}

Fixed version (ground truth):
public String getResponseBody(String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=AsyncHttpProviderUtils.parseCharset(contentType);
  }
  if (charset == null) {
    charset=DEFAULT_CHARSET;
  }
  return contentToString(charset);
}
Program: 115
Project: 115
Buggy source:
public String getResponseBodyExcerpt(int maxLength,String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    parseCharset(contentType);
  }
  if (!contentComputed.get()) {
    contentToString(charset == null ? DEFAULT_CHARSET : charset);
  }
  return content.length() <= maxLength ? content : content.substring(0,maxLength);
}

Fixed version (ground truth):
public String getResponseBodyExcerpt(int maxLength,String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=AsyncHttpProviderUtils.parseCharset(contentType);
  }
  if (charset == null) {
    charset=DEFAULT_CHARSET;
  }
  if (!contentComputed.get()) {
    contentToString(charset == null ? DEFAULT_CHARSET : charset);
  }
  return content.length() <= maxLength ? content : content.substring(0,maxLength);
}
Program: 116
Project: 116
Buggy source:
public String getResponseBody(String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=parseCharset(contentType);
  }
  if (!contentComputed.get()) {
    contentToString(charset);
  }
  return content;
}

Fixed version (ground truth):
public String getResponseBody(String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=AsyncHttpProviderUtils.parseCharset(contentType);
  }
  if (charset == null) {
    charset=DEFAULT_CHARSET;
  }
  if (!contentComputed.get()) {
    contentToString(charset);
  }
  return content;
}
Program: 117
Project: 117
Buggy source:
public String getResponseBodyExcerpt(int maxLength,String charset) throws IOException {
  checkBodyParts();
  String contentType=getContentType();
  if (contentType != null) {
    parseCharset(contentType);
  }
  String response=contentToString(charset);
  return response.length() <= maxLength ? response : response.substring(0,maxLength);
}

Fixed version (ground truth):
public String getResponseBodyExcerpt(int maxLength,String charset) throws IOException {
  checkBodyParts();
  String contentType=getContentType();
  if (contentType != null) {
    charset=AsyncHttpProviderUtils.parseCharset(contentType);
  }
  if (charset == null) {
    charset=DEFAULT_CHARSET;
  }
  String response=contentToString(charset);
  return response.length() <= maxLength ? response : response.substring(0,maxLength);
}
Program: 118
Project: 118
Buggy source:
public String getResponseBody(String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=parseCharset(contentType);
  }
  return contentToString(charset);
}

Fixed version (ground truth):
public String getResponseBody(String charset) throws IOException {
  String contentType=getContentType();
  if (contentType != null) {
    charset=AsyncHttpProviderUtils.parseCharset(contentType);
  }
  if (charset == null) {
    charset=DEFAULT_CHARSET;
  }
  return contentToString(charset);
}
Program: 119
Project: 119
Buggy source:
private void checkBodyParts(){
  if (bodyParts == null && bodyParts.size() > 0) {
    throw new IllegalStateException(BODY_NOT_COMPUTED);
  }
}

Fixed version (ground truth):
private void checkBodyParts(){
  if (bodyParts == null || bodyParts.size() == 0) {
    throw new IllegalStateException(BODY_NOT_COMPUTED);
  }
}
Program: 121
Project: 121
Buggy source:
public JDKResponse(HttpResponseStatus status,HttpResponseHeaders headers,Collection<HttpResponseBodyPart> bodyParts){
  this.bodyParts=bodyParts;
  this.headers=headers;
  this.status=status;
  uri=this.status.getUrl();
  writeHeaders=true;
  writeBody=true;
}

Fixed version (ground truth):
public JDKResponse(HttpResponseStatus status,HttpResponseHeaders headers,Collection<HttpResponseBodyPart> bodyParts){
  this.bodyParts=bodyParts;
  this.headers=headers;
  this.status=status;
  uri=this.status.getUrl();
}
Program: 122
Project: 122
Buggy source:
private void checkBodyParts(){
  if (bodyParts == null && bodyParts.size() > 0) {
    throw new IllegalStateException(BODY_NOT_COMPUTED);
  }
}

Fixed version (ground truth):
private void checkBodyParts(){
  if (bodyParts == null || bodyParts.size() == 0) {
    throw new IllegalStateException(BODY_NOT_COMPUTED);
  }
}
Program: 123
Project: 123
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str","String_Node_Str"}) public void asyncResponseBodyTooLarge() throws Throwable {
  AsyncHttpClient c=getAsyncHttpClient(null);
  Response response=c.prepareGet(getTargetUrl()).execute(new AsyncCompletionHandlerAdapter(){
    @Override public void onThrowable(    Throwable t){
      Assert.fail("String_Node_Str",t);
    }
  }
).get();
  Assert.assertNotNull(response.getResponseBodyExcerpt(Integer.MAX_VALUE));
  c.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str","String_Node_Str"}) public void asyncResponseBodyTooLarge() throws Throwable {
  AsyncHttpClient c=getAsyncHttpClient(null);
  Response response=c.preparePost(getTargetUrl()).setBody("String_Node_Str").execute(new AsyncCompletionHandlerAdapter(){
    @Override public void onThrowable(    Throwable t){
      Assert.fail("String_Node_Str",t);
    }
  }
).get();
  Assert.assertNotNull(response.getResponseBodyExcerpt(Integer.MAX_VALUE));
  c.close();
}
Program: 124
Project: 124
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str"}) public void testOmitErrorBody() throws Throwable {
  SimpleAsyncHttpClient client=new SimpleAsyncHttpClient.Builder().setErrorDocumentBehaviour(ErrorDocumentBehaviour.OMIT).build();
  Request request=new RequestBuilder("String_Node_Str").setUrl(getTargetUrl() + "String_Node_Str").build();
  ByteArrayOutputStream o=new ByteArrayOutputStream(10);
  Future<Response> future=client.get(request,new OutputStreamBodyConsumer(o));
  System.out.println("String_Node_Str");
  Response response=future.get();
  assertEquals(response.getStatusCode(),404);
  assertEquals(o.toString(),"String_Node_Str");
  assertEquals(response.getResponseBody(),"String_Node_Str");
  client.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str"}) public void testOmitErrorBody() throws Throwable {
  SimpleAsyncHttpClient client=new SimpleAsyncHttpClient.Builder().setErrorDocumentBehaviour(ErrorDocumentBehaviour.OMIT).build();
  Request request=new RequestBuilder("String_Node_Str").setUrl(getTargetUrl() + "String_Node_Str").build();
  ByteArrayOutputStream o=new ByteArrayOutputStream(10);
  Future<Response> future=client.get(request,new OutputStreamBodyConsumer(o));
  System.out.println("String_Node_Str");
  Response response=future.get();
  assertEquals(response.getStatusCode(),404);
  assertEquals(o.toString(),"String_Node_Str");
  try {
    response.getResponseBody();
    fail();
  }
 catch (  IllegalStateException e) {
    assertNotNull(e.getMessage());
    assertEquals(e.getMessage(),"String_Node_Str");
  }
  client.close();
}
Program: 126
Project: 126
Buggy source:
private final static int computeAndSetContentLength(Request request,HttpRequest r){
  int lenght=(int)request.getLength();
  if (lenght == -1 && r.getHeader(HttpHeaders.Names.CONTENT_LENGTH) != null) {
    lenght=Integer.valueOf(r.getHeader(HttpHeaders.Names.CONTENT_LENGTH));
  }
  if (lenght != -1) {
    r.setHeader(HttpHeaders.Names.CONTENT_LENGTH,String.valueOf(lenght));
  }
  return lenght;
}

Fixed version (ground truth):
private final static int computeAndSetContentLength(Request request,HttpRequest r){
  int lenght=(int)request.getLength();
  if (lenght == -1 && r.getHeader(HttpHeaders.Names.CONTENT_LENGTH) != null) {
    lenght=Integer.valueOf(r.getHeader(HttpHeaders.Names.CONTENT_LENGTH));
  }
  if (lenght >= 0) {
    r.setHeader(HttpHeaders.Names.CONTENT_LENGTH,String.valueOf(lenght));
  }
  return lenght;
}
Program: 130
Project: 130
Buggy source:
@Override protected void channelIdle(ChannelHandlerContext ctx,IdleState state,long lastActivityTimeMillis) throws Exception {
  if (state.equals(IdleState.READER_IDLE)) {
    return;
  }
  if (NettyResponseFuture.class.isAssignableFrom(ctx.getAttachment().getClass())) {
    NettyResponseFuture<?> future=(NettyResponseFuture<?>)ctx.getAttachment();
    if (!future.isDone() && !future.isCancelled()) {
      return;
    }
    abort(future,new TimeoutException("String_Node_Str" + config.getIdleConnectionTimeoutInMs()));
  }
  log.debug("String_Node_Str",ctx.getChannel());
  closeChannel(ctx);
}

Fixed version (ground truth):
@Override protected void channelIdle(ChannelHandlerContext ctx,IdleState state,long lastActivityTimeMillis) throws Exception {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str",new Object[]{state,System.currentTimeMillis() - lastActivityTimeMillis});
  }
  if (state.equals(IdleState.READER_IDLE)) {
    return;
  }
  if (NettyResponseFuture.class.isAssignableFrom(ctx.getAttachment().getClass())) {
    NettyResponseFuture<?> future=(NettyResponseFuture<?>)ctx.getAttachment();
    if (!future.isDone() && !future.isCancelled()) {
      return;
    }
    abort(future,new TimeoutException("String_Node_Str" + config.getIdleConnectionTimeoutInMs()));
  }
  log.debug("String_Node_Str",ctx.getChannel());
  closeChannel(ctx);
}
Program: 131
Project: 131
Buggy source:
@Test(groups={"String_Node_Str","String_Node_Str"}) public void idleStateTest() throws Throwable {
  isSet.getAndSet(false);
  AsyncHttpClientConfig cg=new AsyncHttpClientConfig.Builder().setIdleConnectionTimeoutInMs(10 * 1000).build();
  AsyncHttpClient c=new AsyncHttpClient(cg);
  try {
    c.prepareGet(getTargetUrl()).execute().get();
  }
 catch (  ExecutionException e) {
    assertEquals(e.getCause().getMessage(),"String_Node_Str");
  }
  c.close();
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str","String_Node_Str"}) public void idleStateTest() throws Throwable {
  isSet.getAndSet(false);
  AsyncHttpClientConfig cg=new AsyncHttpClientConfig.Builder().setIdleConnectionTimeoutInMs(10 * 1000).build();
  AsyncHttpClient c=new AsyncHttpClient(cg);
  try {
    c.prepareGet(getTargetUrl()).execute().get();
    fail("String_Node_Str");
  }
 catch (  ExecutionException e) {
    assertEquals(e.getCause().getMessage(),"String_Node_Str");
  }
 finally {
    c.close();
  }
}
Program: 133
Project: 133
Buggy source:
@Test(groups="String_Node_Str") public void urlWithColonTest_Netty() throws Throwable {
  AsyncHttpClient c=new AsyncHttpClient();
  String query="String_Node_Str";
  Response response=c.prepareGet(String.format("String_Node_Str",port1,query)).setHeader("String_Node_Str","String_Node_Str").execute().get(TIMEOUT,TimeUnit.SECONDS);
  assertEquals(response.getHeader("String_Node_Str"),"String_Node_Str" + URLEncoder.encode(query,"String_Node_Str"));
}

Fixed version (ground truth):
@Test(groups="String_Node_Str") public void urlWithColonTest_Netty() throws Throwable {
  AsyncHttpClient c=new AsyncHttpClient();
  String query="String_Node_Str";
  Response response=c.prepareGet(String.format("String_Node_Str",port1,query)).setHeader("String_Node_Str","String_Node_Str").execute().get(TIMEOUT,TimeUnit.SECONDS);
  assertEquals(response.getHeader("String_Node_Str"),URLEncoder.encode(query,"String_Node_Str"));
}
Program: 134
Project: 134
Buggy source:
@Test(groups="String_Node_Str") public void urlWithColonTest_JDK() throws Throwable {
  AsyncHttpClient c=new AsyncHttpClient(new JDKAsyncHttpProvider(new AsyncHttpClientConfig.Builder().build()));
  String query="String_Node_Str";
  Response response=c.prepareGet(String.format("String_Node_Str",port1,query)).setHeader("String_Node_Str","String_Node_Str").execute().get(TIMEOUT,TimeUnit.SECONDS);
  assertEquals(response.getHeader("String_Node_Str"),"String_Node_Str" + URLEncoder.encode(query,"String_Node_Str"));
}

Fixed version (ground truth):
@Test(groups="String_Node_Str") public void urlWithColonTest_JDK() throws Throwable {
  AsyncHttpClient c=new AsyncHttpClient(new JDKAsyncHttpProvider(new AsyncHttpClientConfig.Builder().build()));
  String query="String_Node_Str";
  Response response=c.prepareGet(String.format("String_Node_Str",port1,query)).setHeader("String_Node_Str","String_Node_Str").execute().get(TIMEOUT,TimeUnit.SECONDS);
  assertEquals(response.getHeader("String_Node_Str"),URLEncoder.encode(query,"String_Node_Str"));
}
Program: 136
Project: 136
Buggy source:
public NettyConnectListener<T> build() throws IOException {
  URI uri=AsyncHttpProviderUtils.createUri(request.getRawUrl().replace("String_Node_Str","String_Node_Str"));
  HttpRequest nettyRequest=NettyAsyncHttpProvider.buildRequest(config,request,uri,true,buffer);
  if (future == null) {
    future=new NettyResponseFuture<T>(uri,request,asyncHandler,nettyRequest,NettyAsyncHttpProvider.requestTimeout(config,request.getPerRequestConfig()),provider);
  }
  return new NettyConnectListener<T>(config,future,nettyRequest);
}

Fixed version (ground truth):
public NettyConnectListener<T> build(final URI uri) throws IOException {
  HttpRequest nettyRequest=NettyAsyncHttpProvider.buildRequest(config,request,uri,true,buffer);
  if (future == null) {
    future=new NettyResponseFuture<T>(uri,request,asyncHandler,nettyRequest,NettyAsyncHttpProvider.requestTimeout(config,request.getPerRequestConfig()),provider);
  }
  return new NettyConnectListener<T>(config,future,nettyRequest);
}
Program: 137
Project: 137
Buggy source:
public void channelClosed(ChannelHandlerContext ctx,ChannelStateEvent e) throws Exception {
  connectionsPool.removeAllConnections(ctx.getChannel());
  Exception exception=null;
  try {
    super.channelClosed(ctx,e);
  }
 catch (  Exception ex) {
    exception=ex;
  }
  if (log.isDebugEnabled()) {
    log.debug(String.format(currentThread() + "String_Node_Str",e.getChannel()));
  }
  if (ctx.getAttachment() instanceof AsyncCallable) {
    AsyncCallable ac=(AsyncCallable)ctx.getAttachment();
    ctx.setAttachment(ac.future());
    ac.call();
    return;
  }
  if (!isClose.get() && ctx.getAttachment() instanceof NettyResponseFuture<?>) {
    NettyResponseFuture<?> future=(NettyResponseFuture<?>)ctx.getAttachment();
    if (future != null && !future.isDone()) {
      remotelyClosed(ctx.getChannel(),future);
    }
  }
}

Fixed version (ground truth):
public void channelClosed(ChannelHandlerContext ctx,ChannelStateEvent e) throws Exception {
  connectionsPool.removeAllConnections(ctx.getChannel());
  Exception exception=null;
  try {
    super.channelClosed(ctx,e);
  }
 catch (  Exception ex) {
    exception=ex;
  }
  if (log.isDebugEnabled()) {
    log.debug(String.format(currentThread() + "String_Node_Str",e.getChannel()));
  }
  if (ctx.getAttachment() instanceof AsyncCallable) {
    AsyncCallable ac=(AsyncCallable)ctx.getAttachment();
    ctx.setAttachment(ac.future());
    ac.call();
    return;
  }
  if (!isClose.get() && ctx.getAttachment() instanceof NettyResponseFuture<?>) {
    NettyResponseFuture<?> future=(NettyResponseFuture<?>)ctx.getAttachment();
    if (future != null && !future.isDone()) {
      remotelyClosed(ctx.getChannel(),future);
    }
  }
 else {
    closeChannel(ctx);
  }
}
Program: 139
Project: 139
Buggy source:
public void operationComplete(ChannelFuture cf){
  Throwable cause=cf.getCause();
  if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) {
    if (ClosedChannelException.class.isAssignableFrom(cause.getClass()) || abortOnReadCloseException(cause) || abortOnWriteCloseException(cause)) {
      if (log.isDebugEnabled()) {
        log.debug(currentThread(),cf.getCause());
      }
      if (future.provider().remotelyClosed(cf.getChannel(),future)) {
        return;
      }
 else {
        future.abort(cause);
      }
    }
 else {
      future.abort(cause);
    }
    return;
  }
  if (ProgressAsyncHandler.class.isAssignableFrom(asyncHandler.getClass())) {
    if (notifyHeaders) {
      ProgressAsyncHandler.class.cast(asyncHandler).onHeaderWriteCompleted();
    }
 else {
      ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteCompleted();
    }
  }
}

Fixed version (ground truth):
public void operationComplete(ChannelFuture cf){
  Throwable cause=cf.getCause();
  if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) {
    if (IllegalStateException.class.isAssignableFrom(cause.getClass())) {
      if (log.isDebugEnabled()) {
        log.debug(cause);
      }
      if (future.provider().remotelyClosed(cf.getChannel(),future)) {
        return;
      }
 else {
        future.abort(cause);
      }
    }
    if (ClosedChannelException.class.isAssignableFrom(cause.getClass()) || abortOnReadCloseException(cause) || abortOnWriteCloseException(cause)) {
      if (log.isDebugEnabled()) {
        log.debug(currentThread(),cf.getCause());
      }
      if (future.provider().remotelyClosed(cf.getChannel(),future)) {
        return;
      }
 else {
        future.abort(cause);
      }
    }
 else {
      future.abort(cause);
    }
    return;
  }
  future.touch();
  if (ProgressAsyncHandler.class.isAssignableFrom(asyncHandler.getClass())) {
    if (notifyHeaders) {
      ProgressAsyncHandler.class.cast(asyncHandler).onHeaderWriteCompleted();
    }
 else {
      ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteCompleted();
    }
  }
}
Program: 140
Project: 140
Buggy source:
V getContent(){
  V update=content.get();
  if (!contentProcessed.getAndSet(true)) {
    try {
      update=asyncHandler.onCompleted();
    }
 catch (    Throwable ex) {
      try {
        asyncHandler.onThrowable(ex);
      }
  finally {
        throw new RuntimeException(ex);
      }
    }
    content.compareAndSet(null,update);
  }
  return update;
}

Fixed version (ground truth):
V getContent() throws ExecutionException {
  ExecutionException e=exEx.getAndSet(null);
  if (e != null) {
    throw e;
  }
  V update=content.get();
  if (exEx.get() == null && !contentProcessed.getAndSet(true)) {
    try {
      update=asyncHandler.onCompleted();
    }
 catch (    Throwable ex) {
      try {
        asyncHandler.onThrowable(ex);
      }
  finally {
        throw new RuntimeException(ex);
      }
    }
    content.compareAndSet(null,update);
  }
  return update;
}