nus-yam/ex-repair huggingface dataset:
Program: 153531
Project: 153531
Buggy source:
@Override public RiakFuture getBucket(final String bucket,final RiakResponseHandler<Bucket> handler){
  notNull(bucket,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  RpbGetBucketReq request=RpbGetBucketReq.newBuilder().setBucket(ByteString.copyFromUtf8(bucket)).build();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbGetBucketResp) {
        RpbGetBucketResp resp=(RpbGetBucketResp)receive;
        RpbBucketProps props=resp.getProps();
        Bucket pb=new PbcBucket(bucket);
        pb.setNumberOfReplicas(props.getNVal());
        pb.setAllowMulti(props.getAllowMult());
        handler.handle(support.newResponse(pb));
        return true;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture getBucket(final String bucket,final RiakResponseHandler<Bucket> handler){
  notNull(bucket,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  RpbGetBucketReq request=RpbGetBucketReq.newBuilder().setBucket(ByteString.copyFromUtf8(bucket)).build();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbGetBucketResp) {
        RpbGetBucketResp resp=(RpbGetBucketResp)receive;
        RpbBucketProps props=resp.getProps();
        Bucket pb=new PbcBucket(bucket);
        pb.setNumberOfReplicas(props.getNVal());
        pb.setAllowMulti(props.getAllowMult());
        handler.handle(PbcRiakOperations.this.support.newResponse(pb));
        return true;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}
Program: 153532
Project: 153532
Buggy source:
@Override public RiakFuture get(final Location location,GetOptions options,final SiblingHandler handler){
  notNull(location,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  RpbGetReq.Builder builder=from(options);
  return _get("String_Node_Str",builder,location,handler,new GetHandler(){
    @Override public void handle(    RpbGetResp resp,    String vclock) throws Exception {
      try {
        handler.begin();
        for (        RpbContent c : resp.getContentList()) {
          RiakObject<byte[]> ro=convert(location,vclock,c);
          handler.handle(support.newResponse(ro));
        }
      }
  finally {
        handler.end();
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture get(final Location location,GetOptions options,final SiblingHandler handler){
  notNull(location,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  RpbGetReq.Builder builder=from(options);
  return _get("String_Node_Str",builder,location,handler,new GetHandler(){
    @Override public void handle(    RpbGetResp resp,    String vclock) throws Exception {
      try {
        handler.begin();
        for (        RpbContent c : resp.getContentList()) {
          RiakObject<byte[]> ro=convert(location,vclock,c);
          handler.handle(PbcRiakOperations.this.support.newResponse(ro));
        }
      }
  finally {
        handler.end();
      }
    }
  }
);
}
Program: 153533
Project: 153533
Buggy source:
protected RiakFuture _delete(final String name,final RiakResponseHandler<_> handler,RpbDelReq.Builder builder){
  return handle(name,builder.build(),handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (MessageCodes.RpbDelResp.equals(receive)) {
        handler.handle(support.newResponse());
        return true;
      }
      throw new IncomprehensibleProtocolException(name);
    }
  }
);
}

Fixed version (ground truth):
protected RiakFuture _delete(final String name,final RiakResponseHandler<_> handler,RpbDelReq.Builder builder){
  return handle(name,builder.build(),handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (MessageCodes.RpbDelResp.equals(receive)) {
        handler.handle(PbcRiakOperations.this.support.newResponse());
        return true;
      }
      throw new IncomprehensibleProtocolException(name);
    }
  }
);
}
Program: 153534
Project: 153534
Buggy source:
@Override public void operationComplete(){
  support.complete();
}

Fixed version (ground truth):
@Override public void operationComplete(){
  PbcRiakOperations.this.support.complete();
}
Program: 153535
Project: 153535
Buggy source:
/** 
 * get server information.
 * @param handler
 * @return
 */
public RiakFuture getServerInfo(final RiakResponseHandler<ServerInfo> handler){
  final String procedure="String_Node_Str";
  return handle(procedure,MessageCodes.RpbGetServerInfoReq,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbGetServerInfoResp) {
        RpbGetServerInfoResp resp=(RpbGetServerInfoResp)receive;
        ServerInfo info=new ServerInfo(to(resp.getNode()),to(resp.getServerVersion()));
        handler.handle(support.newResponse(info));
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * get server information.
 * @param handler
 * @return
 */
public RiakFuture getServerInfo(final RiakResponseHandler<ServerInfo> handler){
  final String procedure="String_Node_Str";
  return handle(procedure,MessageCodes.RpbGetServerInfoReq,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbGetServerInfoResp) {
        RpbGetServerInfoResp resp=(RpbGetServerInfoResp)receive;
        ServerInfo info=new ServerInfo(to(resp.getNode()),to(resp.getServerVersion()));
        handler.handle(PbcRiakOperations.this.support.newResponse(info));
        return true;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}
Program: 153536
Project: 153536
Buggy source:
protected RiakFuture getSingle(RpbGetReq.Builder builder,final Location location,final RiakResponseHandler<RiakObject<byte[]>> handler){
  return _get("String_Node_Str",builder,location,handler,new GetHandler(){
    @Override public void handle(    RpbGetResp resp,    String vclock) throws Exception {
      int size=resp.getContentCount();
      if (1 < size) {
        LOG.warn(Markers.BOUNDARY,Messages.SiblingExists,vclock,size);
      }
      RiakObject<byte[]> ro=convert(location,vclock,resp.getContent(0));
      handler.handle(support.newResponse(ro));
    }
  }
);
}

Fixed version (ground truth):
protected RiakFuture getSingle(RpbGetReq.Builder builder,final Location location,final RiakResponseHandler<RiakObject<byte[]>> handler){
  return _get("String_Node_Str",builder,location,handler,new GetHandler(){
    @Override public void handle(    RpbGetResp resp,    String vclock) throws Exception {
      int size=resp.getContentCount();
      if (1 < size) {
        LOG.warn(Markers.BOUNDARY,Messages.SiblingExists,vclock,size);
      }
      RiakObject<byte[]> ro=convert(location,vclock,resp.getContent(0));
      handler.handle(PbcRiakOperations.this.support.newResponse(ro));
    }
  }
);
}
Program: 153537
Project: 153537
Buggy source:
protected RiakFuture mapReduce(RpbMapRedReq request,final RiakResponseHandler<MapReduceResponse> handler){
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbMapRedResp) {
        RpbMapRedResp resp=(RpbMapRedResp)receive;
        MapReduceResponse response=new PbcMapReduceResponse(resp);
        handler.handle(support.newResponse(response));
        return resp.getDone();
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
protected RiakFuture mapReduce(RpbMapRedReq request,final RiakResponseHandler<MapReduceResponse> handler){
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbMapRedResp) {
        RpbMapRedResp resp=(RpbMapRedResp)receive;
        MapReduceResponse response=new PbcMapReduceResponse(resp);
        handler.handle(PbcRiakOperations.this.support.newResponse(response));
        return resp.getDone();
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}
Program: 153538
Project: 153538
Buggy source:
protected RiakFuture _get(final String name,RpbGetReq.Builder builder,final Location location,final RiakResponseHandler<RiakObject<byte[]>> handler,final GetHandler getHandler){
  RpbGetReq request=builder.setBucket(ByteString.copyFromUtf8(location.getBucket())).setKey(ByteString.copyFromUtf8(location.getKey())).build();
  return handle(name,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbGetResp) {
        RpbGetResp resp=(RpbGetResp)receive;
        int size=resp.getContentCount();
        if (size < 1) {
          handler.onError(new PbcErrorResponse(null){
            public String getMessage(){
              return String.format(Messages.NoContents,location);
            }
            public int getResponseCode(){
              return 1;
            }
          }
);
        }
 else {
          String vclock=toVclock(resp.getVclock());
          getHandler.handle(resp,vclock);
        }
        return true;
      }
      throw new IncomprehensibleProtocolException(name);
    }
  }
);
}

Fixed version (ground truth):
protected RiakFuture _get(final String name,RpbGetReq.Builder builder,final Location location,final RiakResponseHandler<RiakObject<byte[]>> handler,final GetHandler getHandler){
  RpbGetReq request=builder.setBucket(ByteString.copyFromUtf8(location.getBucket())).setKey(ByteString.copyFromUtf8(location.getKey())).build();
  return handle(name,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof RpbGetResp) {
        RpbGetResp resp=(RpbGetResp)receive;
        int size=resp.getContentCount();
        if (size < 1) {
          handler.onError(new PbcErrorResponse(null){
            @Override public String getMessage(){
              return String.format(Messages.NoContents,location);
            }
            @Override public int getResponseCode(){
              return 1;
            }
          }
);
        }
 else {
          String vclock=toVclock(resp.getVclock());
          getHandler.handle(resp,vclock);
        }
        return true;
      }
      throw new IncomprehensibleProtocolException(name);
    }
  }
);
}
Program: 153539
Project: 153539
Buggy source:
/** 
 * Set the client id for this connection. A library may want to set the client id if it has a good way to uniquely identify actors across reconnects. This will reduce vector clock bloat.
 * @param id
 * @param handler
 * @return
 * @see <a
	 *      href="https://github.com/basho/riak_kv/blob/master/src/riak.erl">riak.erl</a>
 */
public RiakFuture setClientId(String id,final RiakResponseHandler<_> handler){
  byte[] bytes=id.getBytes();
  if (4 < bytes.length) {
    throw new IllegalArgumentException(Messages.IllegalClientId);
  }
  RpbSetClientIdReq request=RpbSetClientIdReq.newBuilder().setClientId(ByteString.copyFromUtf8(id)).build();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (MessageCodes.RpbSetClientIdResp.equals(receive)) {
        handler.handle(support.newResponse());
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Set the client id for this connection. A library may want to set the client id if it has a good way to uniquely identify actors across reconnects. This will reduce vector clock bloat.
 * @param id
 * @param handler
 * @return
 * @see <a
	 *      href="https://github.com/basho/riak_kv/blob/master/src/riak.erl">riak.erl</a>
 */
public RiakFuture setClientId(String id,final RiakResponseHandler<_> handler){
  byte[] bytes=id.getBytes();
  if (4 < bytes.length) {
    throw new IllegalArgumentException(Messages.IllegalClientId);
  }
  RpbSetClientIdReq request=RpbSetClientIdReq.newBuilder().setClientId(ByteString.copyFromUtf8(id)).build();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (MessageCodes.RpbSetClientIdResp.equals(receive)) {
        handler.handle(PbcRiakOperations.this.support.newResponse());
        return true;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}
Program: 153540
Project: 153540
Buggy source:
@Test public void testExecute() throws Exception {
  final AtomicBoolean waiter=new AtomicBoolean(false);
  final boolean[] is={false};
  target.execute(new RiakAction<RestRiakOperations>(){
    @Override public void execute(    RestRiakOperations operations){
      operations.ping(new RiakResponseHandler<String>(){
        @Override public void onError(        RiakResponse response) throws RiakException {
          response.operationComplete();
          waiter.compareAndSet(false,true);
        }
        @Override public void handle(        RiakContentsResponse<String> response) throws RiakException {
          try {
            assertEquals("String_Node_Str",response.getContents());
            is[0]=true;
          }
  finally {
            response.operationComplete();
            waiter.compareAndSet(false,true);
          }
        }
      }
);
    }
  }
);
  wait(waiter,is);
}

Fixed version (ground truth):
@Test public void testExecute() throws Exception {
  final CountDownLatch waiter=new CountDownLatch(1);
  final boolean[] is={false};
  this.target.execute(new RiakAction<RestRiakOperations>(){
    @Override public void execute(    RestRiakOperations operations){
      operations.ping(new RiakResponseHandler<String>(){
        @Override public void onError(        RiakResponse response) throws RiakException {
          response.operationComplete();
          waiter.countDown();
        }
        @Override public void handle(        RiakContentsResponse<String> response) throws RiakException {
          try {
            assertEquals("String_Node_Str",response.getContents());
            is[0]=true;
          }
  finally {
            response.operationComplete();
            waiter.countDown();
          }
        }
      }
);
    }
  }
);
  wait(waiter,is);
}
Program: 153541
Project: 153541
Buggy source:
protected void wait(final AtomicBoolean waiter,final boolean[] is) throws InterruptedException {
  while (waiter.get() == false) {
    Thread.sleep(10);
  }
  assertTrue(is[0]);
}

Fixed version (ground truth):
protected void wait(final CountDownLatch waiter,final boolean[] is) throws InterruptedException {
  waiter.await(3,TimeUnit.SECONDS);
  assertTrue(is[0]);
}
Program: 153542
Project: 153542
Buggy source:
@Override public void onError(RiakResponse response) throws RiakException {
  response.operationComplete();
  waiter.compareAndSet(false,true);
}

Fixed version (ground truth):
@Override public void onError(RiakResponse response) throws RiakException {
  response.operationComplete();
  waiter.countDown();
}
Program: 153543
Project: 153543
Buggy source:
@Before public void setUp() throws Exception {
  target=new RestRiakClient(DefaultConfig.newConfig(Hosts.RIAK_HOST,Hosts.RIAK_HTTP_PORT));
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  this.target=new RestRiakClient(DefaultConfig.newConfig(Hosts.RIAK_HOST,Hosts.RIAK_HTTP_PORT));
}
Program: 153544
Project: 153544
Buggy source:
@Override public void handle(RiakContentsResponse<String> response) throws RiakException {
  try {
    assertEquals("String_Node_Str",response.getContents());
    is[0]=true;
  }
  finally {
    response.operationComplete();
    waiter.compareAndSet(false,true);
  }
}

Fixed version (ground truth):
@Override public void handle(RiakContentsResponse<String> response) throws RiakException {
  try {
    assertEquals("String_Node_Str",response.getContents());
    is[0]=true;
  }
  finally {
    response.operationComplete();
    waiter.countDown();
  }
}
Program: 153545
Project: 153545
Buggy source:
@Override public void execute(RestRiakOperations operations){
  operations.ping(new RiakResponseHandler<String>(){
    @Override public void onError(    RiakResponse response) throws RiakException {
      response.operationComplete();
      waiter.compareAndSet(false,true);
    }
    @Override public void handle(    RiakContentsResponse<String> response) throws RiakException {
      try {
        assertEquals("String_Node_Str",response.getContents());
        is[0]=true;
      }
  finally {
        response.operationComplete();
        waiter.compareAndSet(false,true);
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void execute(RestRiakOperations operations){
  operations.ping(new RiakResponseHandler<String>(){
    @Override public void onError(    RiakResponse response) throws RiakException {
      response.operationComplete();
      waiter.countDown();
    }
    @Override public void handle(    RiakContentsResponse<String> response) throws RiakException {
      try {
        assertEquals("String_Node_Str",response.getContents());
        is[0]=true;
      }
  finally {
        response.operationComplete();
        waiter.countDown();
      }
    }
  }
);
}
Program: 153546
Project: 153546
Buggy source:
@After public void tearDown(){
  target.dispose();
}

Fixed version (ground truth):
@After public void tearDown(){
  this.target.dispose();
}
Program: 153547
Project: 153547
Buggy source:
@Override public RiakFuture getStats(final RiakResponseHandler<ObjectNode> handler){
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newGetStatsRequest();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          ObjectNode node=to(response.getContent());
          handler.handle(RestRiakOperations.this.support.newResponse(node));
          return true;
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture getStats(final RiakResponseHandler<ObjectNode> handler){
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newGetStatsRequest();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          ObjectNode node=to(response.getContent());
          handler.handle(RestRiakOperations.this.support.newResponse(node));
          return true;
        }
      }
      return false;
    }
  }
);
}
Program: 153548
Project: 153548
Buggy source:
@Override public RiakFuture postStream(final RiakObject<InputStreamHandler> content,final RiakResponseHandler<String> handler){
  notNull(content,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newStreamRequest(content,"String_Node_Str",HttpMethod.POST);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        HttpResponseStatus status=response.getStatus();
        if (HttpResponseStatus.CONTINUE.equals(status)) {
          InputStreamHandler ish=content.getContent();
          RestRiakOperations.this.channel.write(new ChunkedStream(ish.open()));
          return false;
        }
 else         if (HttpResponseStatus.CREATED.equals(status)) {
          String loc=response.getHeader(HttpHeaders.Names.LOCATION);
          if (StringUtil.isEmpty(loc) == false && loc.startsWith("String_Node_Str" + RestRiakOperations.this.config.getLuwakName() + "String_Node_Str")) {
            final String newKey=loc.substring(7);
            handler.handle(RestRiakOperations.this.support.newResponse(newKey));
            return true;
          }
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture postStream(final RiakObject<InputStreamHandler> content,final RiakResponseHandler<String> handler){
  notNull(content,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newStreamRequest(content,"String_Node_Str",HttpMethod.POST);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        HttpResponseStatus status=response.getStatus();
        if (HttpResponseStatus.CONTINUE.equals(status)) {
          InputStreamHandler ish=content.getContent();
          RestRiakOperations.this.channel.write(new ChunkedStream(ish.open()));
          return false;
        }
 else         if (HttpResponseStatus.CREATED.equals(status)) {
          String loc=response.getHeader(HttpHeaders.Names.LOCATION);
          if (StringUtil.isEmpty(loc) == false && loc.startsWith("String_Node_Str" + RestRiakOperations.this.config.getLuwakName() + "String_Node_Str")) {
            final String newKey=loc.substring(7);
            handler.handle(RestRiakOperations.this.support.newResponse(newKey));
            return true;
          }
        }
      }
      return false;
    }
  }
);
}
Program: 153549
Project: 153549
Buggy source:
@Override public RiakFuture listKeys(String bucket,final RiakResponseHandler<KeyResponse> handler){
  notNull(bucket,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newListKeysRequest(bucket);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          boolean done=response.isChunked() == false;
          if (done) {
            _listKeys(response.getContent(),handler);
          }
          return done;
        }
      }
 else       if (receive instanceof HttpChunk) {
        HttpChunk chunk=(HttpChunk)receive;
        boolean done=chunk.isLast();
        if (done == false) {
          _listKeys(chunk.getContent(),handler);
        }
        return done;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture listKeys(String bucket,final RiakResponseHandler<KeyResponse> handler){
  notNull(bucket,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newListKeysRequest(bucket);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          boolean done=response.isChunked() == false;
          if (done) {
            _listKeys(response.getContent(),handler);
          }
          return done;
        }
      }
 else       if (receive instanceof HttpChunk) {
        HttpChunk chunk=(HttpChunk)receive;
        boolean done=chunk.isLast();
        if (done == false) {
          _listKeys(chunk.getContent(),handler);
        }
        return done;
      }
      return false;
    }
  }
);
}
Program: 153550
Project: 153550
Buggy source:
@Override public RiakFuture listBuckets(final RiakResponseHandler<List<String>> handler){
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newListBucketsRequest();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        ChannelBuffer buffer=response.getContent();
        ObjectNode node=to(buffer);
        if (node != null) {
          List<String> list=JsonUtil.to(node.get("String_Node_Str"));
          handler.handle(RestRiakOperations.this.support.newResponse(list));
          return true;
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture listBuckets(final RiakResponseHandler<List<String>> handler){
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newListBucketsRequest();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        ChannelBuffer buffer=response.getContent();
        ObjectNode node=to(buffer);
        if (node != null) {
          List<String> list=JsonUtil.to(node.get("String_Node_Str"));
          handler.handle(RestRiakOperations.this.support.newResponse(list));
          return true;
        }
      }
      return false;
    }
  }
);
}
Program: 153551
Project: 153551
Buggy source:
@Override public RiakFuture ping(final RiakResponseHandler<String> handler){
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newPingRequest();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          handler.handle(RestRiakOperations.this.support.newResponse("String_Node_Str"));
          return true;
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture ping(final RiakResponseHandler<String> handler){
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newPingRequest();
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          handler.handle(RestRiakOperations.this.support.newResponse("String_Node_Str"));
          return true;
        }
      }
      return false;
    }
  }
);
}
Program: 153552
Project: 153552
Buggy source:
@Override public RiakFuture putStream(final RiakObject<InputStreamHandler> content,final RiakResponseHandler<_> handler){
  notNull(content,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newStreamRequest(content,content.getLocation().getKey(),HttpMethod.PUT);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        HttpResponseStatus status=response.getStatus();
        if (HttpResponseStatus.CONTINUE.equals(status)) {
          InputStreamHandler ish=content.getContent();
          RestRiakOperations.this.channel.write(new ChunkedStream(ish.open()));
          return false;
        }
 else         if (NettyUtil.isSuccessful(status)) {
          handler.handle(RestRiakOperations.this.support.newResponse());
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture putStream(final RiakObject<InputStreamHandler> content,final RiakResponseHandler<_> handler){
  notNull(content,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newStreamRequest(content,content.getLocation().getKey(),HttpMethod.PUT);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        HttpResponseStatus status=response.getStatus();
        if (HttpResponseStatus.CONTINUE.equals(status)) {
          InputStreamHandler ish=content.getContent();
          RestRiakOperations.this.channel.write(new ChunkedStream(ish.open()));
          return false;
        }
 else         if (NettyUtil.isSuccessful(status)) {
          handler.handle(RestRiakOperations.this.support.newResponse());
          return true;
        }
      }
      return false;
    }
  }
);
}
Program: 153553
Project: 153553
Buggy source:
/** 
 * if returning body has sibling then call get with sibling call automatically.
 */
@Override public RiakFuture put(final RiakObject<byte[]> content,final PutOptions options,final SiblingHandler handler){
  notNull(content,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newPutRequest(content,options);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          try {
            handler.begin();
            RiakObject<byte[]> ro=RestRiakOperations.this.factory.convert(response,response.getContent(),content.getLocation());
            handler.handle(RestRiakOperations.this.support.newResponse(ro));
          }
  finally {
            handler.end(RestRiakOperations.this.support.newResponse());
          }
        }
 else         if (response.getStatus().getCode() == 300) {
          dispatchToGetSibling(content.getLocation(),options,handler);
        }
        return true;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * if returning body has sibling then call get with sibling call automatically.
 */
@Override public RiakFuture put(final RiakObject<byte[]> content,final PutOptions options,final SiblingHandler handler){
  notNull(content,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newPutRequest(content,options);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          try {
            handler.begin();
            RiakObject<byte[]> ro=RestRiakOperations.this.factory.convert(response,response.getContent(),content.getLocation());
            handler.handle(RestRiakOperations.this.support.newResponse(ro));
          }
  finally {
            handler.end(RestRiakOperations.this.support.newResponse());
          }
        }
 else         if (response.getStatus().getCode() == 300) {
          dispatchToGetSibling(content.getLocation(),options,handler);
        }
        return true;
      }
      return false;
    }
  }
);
}
Program: 153554
Project: 153554
Buggy source:
private RiakFuture _post(final String procedure,RiakObject<byte[]> content,final RiakResponseHandler<RiakObject<byte[]>> handler,HttpRequest request){
  final RiakObject<byte[]> copied=new DefaultRiakObject(content);
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          Location location=to(response);
          if (location != null) {
            copied.setLocation(location);
            handler.handle(RestRiakOperations.this.support.newResponse(copied));
            return true;
          }
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
private RiakFuture _post(final String procedure,RiakObject<byte[]> content,final RiakResponseHandler<RiakObject<byte[]>> handler,HttpRequest request){
  final RiakObject<byte[]> copied=new DefaultRiakObject(content);
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          Location location=to(response);
          if (location != null) {
            copied.setLocation(location);
            handler.handle(RestRiakOperations.this.support.newResponse(copied));
            return true;
          }
        }
      }
      return false;
    }
  }
);
}
Program: 153555
Project: 153555
Buggy source:
@Override public RiakFuture getBucket(String bucket,final RiakResponseHandler<Bucket> handler){
  notNull(bucket,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newGetBucketRequest(bucket);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          ObjectMapper objectMapper=new ObjectMapper();
          BucketHolder holder=objectMapper.readValue(new ChannelBufferInputStream(response.getContent()),BucketHolder.class);
          handler.handle(RestRiakOperations.this.support.newResponse(holder.props));
          return true;
        }
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture getBucket(String bucket,final RiakResponseHandler<Bucket> handler){
  notNull(bucket,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newGetBucketRequest(bucket);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        if (NettyUtil.isSuccessful(response.getStatus())) {
          ObjectMapper objectMapper=new ObjectMapper();
          BucketHolder holder=objectMapper.readValue(new ChannelBufferInputStream(response.getContent()),BucketHolder.class);
          handler.handle(RestRiakOperations.this.support.newResponse(holder.props));
          return true;
        }
      }
      return false;
    }
  }
);
}
Program: 153556
Project: 153556
Buggy source:
@Override public RiakFuture post(RiakObject<byte[]> content,PutOptions options,final RiakResponseHandler<RiakObject<byte[]>> handler){
  notNull(content,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newPostRequest(content,options);
  if (options.getReturnBody() == false) {
    return _post("String_Node_Str",content,handler,request);
  }
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.ChunkedMessageAggregator(procedure,new NettyUtil.ChunkedMessageHandler(){
    @Override public void handle(    HttpResponse response,    ChannelBuffer buffer) throws Exception {
      Location location=to(response);
      if (location == null) {
        throw new IncomprehensibleProtocolException(procedure);
      }
      RiakObject<byte[]> ro=RestRiakOperations.this.factory.convert(response,buffer,location);
      handler.handle(RestRiakOperations.this.support.newResponse(ro));
    }
  }
));
}

Fixed version (ground truth):
@Override public RiakFuture post(RiakObject<byte[]> content,PutOptions options,final RiakResponseHandler<RiakObject<byte[]>> handler){
  notNull(content,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newPostRequest(content,options);
  if (options.getReturnBody() == false) {
    return _post("String_Node_Str",content,handler,request);
  }
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.ChunkedMessageAggregator(procedure,new NettyUtil.ChunkedMessageHandler(){
    @Override public void handle(    HttpResponse response,    ChannelBuffer buffer) throws Exception {
      Location location=to(response);
      if (location == null) {
        throw new IllegalStateException();
      }
      RiakObject<byte[]> ro=RestRiakOperations.this.factory.convert(response,buffer,location);
      handler.handle(RestRiakOperations.this.support.newResponse(ro));
    }
  }
));
}
Program: 153557
Project: 153557
Buggy source:
@Override public RiakFuture get(final Location location,GetOptions options,final SiblingHandler handler){
  notNull(location,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newGetRequst(location,options);
  request.setHeader(HttpHeaders.Names.ACCEPT,RiakHttpHeaders.MULTI_PART);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    String vclock;
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        this.vclock=response.getHeader(RiakHttpHeaders.VECTOR_CLOCK);
        handler.begin();
        return false;
      }
 else       if (receive instanceof PartMessage) {
        PartMessage part=(PartMessage)receive;
        boolean done=part.isLast();
        part.setHeader(RiakHttpHeaders.VECTOR_CLOCK,this.vclock);
        if (done) {
          handler.end(RestRiakOperations.this.support.newResponse());
        }
 else {
          RiakObject<byte[]> ro=RestRiakOperations.this.factory.convert(part,part.getContent(),location);
          handler.handle(RestRiakOperations.this.support.newResponse(ro));
        }
        return done;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture get(final Location location,GetOptions options,final SiblingHandler handler){
  notNull(location,"String_Node_Str");
  notNull(options,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newGetRequst(location,options);
  request.setHeader(HttpHeaders.Names.ACCEPT,RiakHttpHeaders.MULTI_PART);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    String vclock;
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        this.vclock=response.getHeader(RiakHttpHeaders.VECTOR_CLOCK);
        handler.begin();
        return false;
      }
 else       if (receive instanceof PartMessage) {
        PartMessage part=(PartMessage)receive;
        boolean done=part.isLast();
        part.setHeader(RiakHttpHeaders.VECTOR_CLOCK,this.vclock);
        if (done) {
          handler.end(RestRiakOperations.this.support.newResponse());
        }
 else {
          RiakObject<byte[]> ro=RestRiakOperations.this.factory.convert(part,part.getContent(),location);
          handler.handle(RestRiakOperations.this.support.newResponse(ro));
        }
        return done;
      }
      return false;
    }
  }
);
}
Program: 153558
Project: 153558
Buggy source:
protected RiakFuture _getStream(final String procedure,HttpRequest request,final StreamResponseHandler handler){
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        boolean done=response.isChunked() == false;
        RiakObject<_> ro=new AbstractRiakObject<_>(){
          @Override public _ getContent(){
            return _._;
          }
        }
;
        RestRiakOperations.this.factory.convertHeaders(response,ro);
        handler.begin(ro);
        if (done) {
          try {
            handler.handle(RestRiakOperations.this.support.newResponse(response.getContent()));
          }
  finally {
            handler.end();
          }
        }
        return done;
      }
 else       if (receive instanceof HttpChunk) {
        HttpChunk chunk=(HttpChunk)receive;
        boolean done=chunk.isLast();
        if (done) {
          handler.end();
        }
 else {
          handler.handle(RestRiakOperations.this.support.newResponse(chunk.getContent()));
        }
        return done;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
protected RiakFuture _getStream(final String procedure,HttpRequest request,final StreamResponseHandler handler){
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        HttpResponse response=(HttpResponse)receive;
        boolean done=response.isChunked() == false;
        RiakObject<_> ro=new AbstractRiakObject<_>(){
          @Override public _ getContent(){
            return _._;
          }
        }
;
        RestRiakOperations.this.factory.convertHeaders(response,ro);
        handler.begin(ro);
        if (done) {
          try {
            handler.handle(RestRiakOperations.this.support.newResponse(response.getContent()));
          }
  finally {
            handler.end();
          }
        }
        return done;
      }
 else       if (receive instanceof HttpChunk) {
        HttpChunk chunk=(HttpChunk)receive;
        boolean done=chunk.isLast();
        if (done) {
          handler.end();
        }
 else {
          handler.handle(RestRiakOperations.this.support.newResponse(chunk.getContent()));
        }
        return done;
      }
      return false;
    }
  }
);
}
Program: 153559
Project: 153559
Buggy source:
@Override public boolean handle(Object receive) throws Exception {
  if (receive instanceof HttpResponse) {
    HttpResponse response=(HttpResponse)receive;
    HttpResponseStatus status=response.getStatus();
    if (HttpResponseStatus.CONTINUE.equals(status)) {
      InputStreamHandler ish=content.getContent();
      RestRiakOperations.this.channel.write(new ChunkedStream(ish.open()));
      return false;
    }
 else     if (NettyUtil.isSuccessful(status)) {
      handler.handle(RestRiakOperations.this.support.newResponse());
    }
  }
  throw new IncomprehensibleProtocolException(procedure);
}

Fixed version (ground truth):
@Override public boolean handle(Object receive) throws Exception {
  if (receive instanceof HttpResponse) {
    HttpResponse response=(HttpResponse)receive;
    HttpResponseStatus status=response.getStatus();
    if (HttpResponseStatus.CONTINUE.equals(status)) {
      InputStreamHandler ish=content.getContent();
      RestRiakOperations.this.channel.write(new ChunkedStream(ish.open()));
      return false;
    }
 else     if (NettyUtil.isSuccessful(status)) {
      handler.handle(RestRiakOperations.this.support.newResponse());
      return true;
    }
  }
  return false;
}
Program: 153560
Project: 153560
Buggy source:
@Override public RiakFuture walk(Location walkbegin,List<LinkCondition> conditions,final RiakResponseHandler<List<RiakObject<byte[]>>> handler){
  notNull(walkbegin,"String_Node_Str");
  notNull(conditions,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newWalkRequst(walkbegin,conditions);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        return false;
      }
 else       if (receive instanceof PartMessage) {
        PartMessage part=(PartMessage)receive;
        boolean done=part.isLast();
        if (done == false) {
          notifyStep(part,handler);
        }
        return done;
      }
      throw new IncomprehensibleProtocolException(procedure);
    }
  }
);
}

Fixed version (ground truth):
@Override public RiakFuture walk(Location walkbegin,List<LinkCondition> conditions,final RiakResponseHandler<List<RiakObject<byte[]>>> handler){
  notNull(walkbegin,"String_Node_Str");
  notNull(conditions,"String_Node_Str");
  notNull(handler,"String_Node_Str");
  HttpRequest request=this.factory.newWalkRequst(walkbegin,conditions);
  final String procedure="String_Node_Str";
  return handle(procedure,request,handler,new NettyUtil.MessageHandler(){
    @Override public boolean handle(    Object receive) throws Exception {
      if (receive instanceof HttpResponse) {
        return false;
      }
 else       if (receive instanceof PartMessage) {
        PartMessage part=(PartMessage)receive;
        boolean done=part.isLast();
        if (done == false) {
          notifyStep(part,handler);
        }
        return done;
      }
      return false;
    }
  }
);
}
Program: 153561
Project: 153561
Buggy source:
@Override public boolean handle(Object receive) throws Exception {
  if (receive instanceof HttpResponse) {
    HttpResponse response=(HttpResponse)receive;
    HttpResponseStatus status=response.getStatus();
    if (NettyUtil.isError(status)) {
      users.onError(new RestErrorResponse(response,support));
      return true;
    }
    if (NettyUtil.isSuccessful(status)) {
      users.handle(support.newResponse());
      return true;
    }
  }
  throw new IncomprehensibleProtocolException(name);
}

Fixed version (ground truth):
@Override public boolean handle(Object receive) throws Exception {
  if (receive instanceof HttpResponse) {
    HttpResponse response=(HttpResponse)receive;
    HttpResponseStatus status=response.getStatus();
    if (NettyUtil.isError(status)) {
      this.users.onError(new RestErrorResponse(response,this.support));
      return true;
    }
    if (NettyUtil.isSuccessful(status)) {
      this.users.handle(this.support.newResponse());
      return true;
    }
  }
  return false;
}
Program: 153562
Project: 153562
Buggy source:
boolean cancel();

Fixed version (ground truth):
void cancel();