nus-yam/ex-repair huggingface dataset:
Program: 113752
Project: 113752
Buggy source:
public RPCNIOSocketClient(SSLOptions sslOptions,int requestTimeout,int connectionTimeout) throws IOException {
  super("String_Node_Str");
  if (requestTimeout >= connectionTimeout - TIMEOUT_GRANULARITY * 2) {
    throw new IllegalArgumentException("String_Node_Str" + TIMEOUT_GRANULARITY * 2 + "String_Node_Str");
  }
  this.requestTimeout=requestTimeout;
  this.connectionTimeout=connectionTimeout;
  connections=new HashMap();
  selector=Selector.open();
  this.sslOptions=sslOptions;
  quit=false;
  transactionId=new AtomicInteger(1);
  toBeEstablished=new ConcurrentLinkedQueue<ServerConnection>();
}

Fixed version (ground truth):
public RPCNIOSocketClient(SSLOptions sslOptions,int requestTimeout,int connectionTimeout) throws IOException {
  super("String_Node_Str");
  if (requestTimeout >= connectionTimeout - TIMEOUT_GRANULARITY * 2) {
    throw new IllegalArgumentException("String_Node_Str" + TIMEOUT_GRANULARITY * 2 + "String_Node_Str");
  }
  this.requestTimeout=requestTimeout;
  this.connectionTimeout=connectionTimeout;
  connections=new HashMap();
  selector=Selector.open();
  this.sslOptions=sslOptions;
  quit=false;
  transactionId=new AtomicInteger((int)(Math.random() * 1e6 + 1.0));
  toBeEstablished=new ConcurrentLinkedQueue<ServerConnection>();
}
Program: 113756
Project: 113756
Buggy source:
public void sendInternalServerError(){
}

Fixed version (ground truth):
public void sendInternalServerError(Throwable rootCause){
  rpcRequest.sendInternalServerError(rootCause);
}
Program: 113757
Project: 113757
Buggy source:
public void sendException(Serializable exception){
  if (Logging.isDebug()) {
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + exception);
  }
  rpcRequest.sendGenericException(exception);
}

Fixed version (ground truth):
public void sendException(ONCRPCException exception){
  if (Logging.isDebug()) {
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + exception);
  }
  rpcRequest.sendGenericException(exception);
}
Program: 113758
Project: 113758
Buggy source:
public void processRequest(ONCRPCRequest rq){
  final ONCRPCRequestHeader hdr=rq.getRequestHeader();
  if (hdr.getInterfaceVersion() != DIRInterface.getVersion()) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROG_MISMATCH,0,"String_Node_Str"));
    return;
  }
  DIROperation op=registry.get(hdr.getOperationNumber());
  if (op == null) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROC_UNAVAIL,0,"String_Node_Str"));
    return;
  }
  DIRRequest dirRq=new DIRRequest(rq);
  try {
    op.parseRPCMessage(dirRq);
    numRequests++;
    op.startRequest(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendGarbageArgs(new errnoException(ErrNo.EINVAL,ex.toString(),"String_Node_Str"));
    return;
  }
}

Fixed version (ground truth):
public void processRequest(ONCRPCRequest rq){
  final ONCRPCRequestHeader hdr=rq.getRequestHeader();
  if (hdr.getInterfaceVersion() != DIRInterface.getVersion()) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROG_MISMATCH,0,"String_Node_Str"));
    return;
  }
  DIROperation op=registry.get(hdr.getOperationNumber());
  if (op == null) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROC_UNAVAIL,0,"String_Node_Str"));
    return;
  }
  DIRRequest dirRq=new DIRRequest(rq);
  try {
    op.parseRPCMessage(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendGarbageArgs(ex.toString());
    return;
  }
  try {
    op.parseRPCMessage(dirRq);
    numRequests++;
    op.startRequest(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendInternalServerError(ex);
    return;
  }
}
Program: 113759
Project: 113759
Buggy source:
@Override public void startRequest(DIRRequest rq){
  try {
    final address_mappings_deleteRequest request=(address_mappings_deleteRequest)rq.getRequestMessage();
    BabuDBInsertGroup ig=database.createInsertGroup(DIRRequestDispatcher.DB_NAME);
    ig.addDelete(DIRRequestDispatcher.INDEX_ID_ADDRMAPS,request.getUuid().getBytes());
    database.directInsert(ig);
    address_mappings_deleteResponse response=new address_mappings_deleteResponse();
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
}

Fixed version (ground truth):
@Override public void startRequest(DIRRequest rq){
  try {
    final address_mappings_deleteRequest request=(address_mappings_deleteRequest)rq.getRequestMessage();
    BabuDBInsertGroup ig=database.createInsertGroup(DIRRequestDispatcher.DB_NAME);
    ig.addDelete(DIRRequestDispatcher.INDEX_ID_ADDRMAPS,request.getUuid().getBytes());
    database.directInsert(ig);
    address_mappings_deleteResponse response=new address_mappings_deleteResponse();
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError(ex);
  }
}
Program: 113760
Project: 113760
Buggy source:
@Override public void startRequest(DIRRequest rq){
  try {
    final service_deregisterRequest request=(service_deregisterRequest)rq.getRequestMessage();
    BabuDBInsertGroup ig=database.createInsertGroup(DIRRequestDispatcher.DB_NAME);
    ig.addDelete(DIRRequestDispatcher.INDEX_ID_SERVREG,request.getUuid().getBytes());
    database.directInsert(ig);
    service_deregisterResponse response=new service_deregisterResponse();
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
}

Fixed version (ground truth):
@Override public void startRequest(DIRRequest rq){
  try {
    final service_deregisterRequest request=(service_deregisterRequest)rq.getRequestMessage();
    BabuDBInsertGroup ig=database.createInsertGroup(DIRRequestDispatcher.DB_NAME);
    ig.addDelete(DIRRequestDispatcher.INDEX_ID_SERVREG,request.getUuid().getBytes());
    database.directInsert(ig);
    service_deregisterResponse response=new service_deregisterResponse();
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError(ex);
  }
}
Program: 113761
Project: 113761
Buggy source:
@Override public void startRequest(DIRRequest rq){
  try {
    final address_mappings_getRequest request=(address_mappings_getRequest)rq.getRequestMessage();
    byte[] result=database.directLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_ADDRMAPS,request.getUuid().getBytes());
    if (result == null) {
      address_mappings_getResponse response=new address_mappings_getResponse();
      rq.sendSuccess(response);
    }
 else {
      AddressMappingSet set=new AddressMappingSet();
      set.deserialize(ReusableBuffer.wrap(result));
      address_mappings_getResponse response=new address_mappings_getResponse(set);
      rq.sendSuccess(response);
    }
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
}

Fixed version (ground truth):
@Override public void startRequest(DIRRequest rq){
  try {
    final address_mappings_getRequest request=(address_mappings_getRequest)rq.getRequestMessage();
    byte[] result=database.directLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_ADDRMAPS,request.getUuid().getBytes());
    if (result == null) {
      address_mappings_getResponse response=new address_mappings_getResponse();
      rq.sendSuccess(response);
    }
 else {
      AddressMappingSet set=new AddressMappingSet();
      set.deserialize(ReusableBuffer.wrap(result));
      address_mappings_getResponse response=new address_mappings_getResponse(set);
      rq.sendSuccess(response);
    }
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError(ex);
  }
}
Program: 113762
Project: 113762
Buggy source:
@Override public void startRequest(DIRRequest rq){
  try {
    final service_get_by_uuidRequest request=(service_get_by_uuidRequest)rq.getRequestMessage();
    byte[] data=database.directLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_SERVREG,request.getUuid().getBytes());
    ServiceRegistrySet services=new ServiceRegistrySet();
    if (data != null) {
      ServiceRegistry dbData=new ServiceRegistry();
      ReusableBuffer buf=ReusableBuffer.wrap(data);
      dbData.deserialize(buf);
      services.add(dbData);
    }
    service_get_by_uuidResponse response=new service_get_by_uuidResponse(services);
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
}

Fixed version (ground truth):
@Override public void startRequest(DIRRequest rq){
  try {
    final service_get_by_uuidRequest request=(service_get_by_uuidRequest)rq.getRequestMessage();
    byte[] data=database.directLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_SERVREG,request.getUuid().getBytes());
    ServiceRegistrySet services=new ServiceRegistrySet();
    if (data != null) {
      ServiceRegistry dbData=new ServiceRegistry();
      ReusableBuffer buf=ReusableBuffer.wrap(data);
      dbData.deserialize(buf);
      services.add(dbData);
    }
    service_get_by_uuidResponse response=new service_get_by_uuidResponse(services);
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError(ex);
  }
}
Program: 113763
Project: 113763
Buggy source:
@Override public void startRequest(DIRRequest rq){
  try {
    final service_get_by_typeRequest request=(service_get_by_typeRequest)rq.getRequestMessage();
    Iterator<Entry<byte[],byte[]>> iter=database.directPrefixLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_SERVREG,new byte[0]);
    ServiceRegistrySet services=new ServiceRegistrySet();
    while (iter.hasNext()) {
      final Entry<byte[],byte[]> e=iter.next();
      final ServiceRegistry servEntry=new ServiceRegistry();
      ReusableBuffer buf=ReusableBuffer.wrap(e.getValue());
      servEntry.deserialize(buf);
      if (servEntry.getService_type() == request.getType())       services.add(servEntry);
    }
    service_get_by_typeResponse response=new service_get_by_typeResponse(services);
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
}

Fixed version (ground truth):
@Override public void startRequest(DIRRequest rq){
  try {
    final service_get_by_typeRequest request=(service_get_by_typeRequest)rq.getRequestMessage();
    Iterator<Entry<byte[],byte[]>> iter=database.directPrefixLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_SERVREG,new byte[0]);
    ServiceRegistrySet services=new ServiceRegistrySet();
    while (iter.hasNext()) {
      final Entry<byte[],byte[]> e=iter.next();
      final ServiceRegistry servEntry=new ServiceRegistry();
      ReusableBuffer buf=ReusableBuffer.wrap(e.getValue());
      servEntry.deserialize(buf);
      if (servEntry.getService_type() == request.getType())       services.add(servEntry);
    }
    service_get_by_typeResponse response=new service_get_by_typeResponse(services);
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + response);
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError(ex);
  }
}
Program: 113767
Project: 113767
Buggy source:
public void sendInternalServerError(errnoException exception){
}

Fixed version (ground truth):
public void sendInternalServerError(Throwable rootCause){
}
Program: 113768
Project: 113768
Buggy source:
public void sendGarbageArgs(errnoException exception){
}

Fixed version (ground truth):
public void sendGarbageArgs(String message){
}
Program: 113769
Project: 113769
Buggy source:
public void sendGenericException(Serializable exception){
}

Fixed version (ground truth):
public void sendGenericException(ONCRPCException exception){
}
Program: 113770
Project: 113770
Buggy source:
public static ONCRPCException createException(String exception_type_name) throws java.io.IOException {
  if (exception_type_name.equals("String_Node_Str"))   return new ProtocolException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new errnoException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new RedirectException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new ConcurrentModificationException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new InvalidArgumentException();
 else   throw new java.io.IOException("String_Node_Str" + exception_type_name);
}

Fixed version (ground truth):
public static ONCRPCException createException(String exception_type_name) throws java.io.IOException {
  if (exception_type_name.equals("String_Node_Str"))   return new ProtocolException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new errnoException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new RedirectException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new MRCException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new OSDException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new ConcurrentModificationException();
 else   if (exception_type_name.equals("String_Node_Str"))   return new InvalidArgumentException();
 else   throw new java.io.IOException("String_Node_Str" + exception_type_name);
}
Program: 113771
Project: 113771
Buggy source:
public XLocations(XLocSet xloc,ServiceUUID localOSD){
  this(xloc);
  System.out.println("String_Node_Str" + localOSD);
  for (  Replica r : replicas) {
    System.out.println("String_Node_Str" + r.getOSDs());
    if (r.getOSDs().contains(localOSD)) {
      localReplica=r;
      break;
    }
  }
  if (localReplica == null)   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
public XLocations(XLocSet xloc,ServiceUUID localOSD){
  this(xloc);
  for (  Replica r : replicas) {
    if (r.getOSDs().contains(localOSD)) {
      localReplica=r;
      break;
    }
  }
  if (localReplica == null)   throw new IllegalArgumentException("String_Node_Str");
}
Program: 113772
Project: 113772
Buggy source:
public static Request createRequest(ONCRPCRequestHeader header) throws Exception {
switch (header.getOperationNumber()) {
case 1:
    return new readRequest();
case 2:
  return new truncateRequest();
case 3:
return new unlinkRequest();
case 4:
return new writeRequest();
case 100:
return new internal_get_gmaxRequest();
case 101:
return new internal_truncateRequest();
case 102:
return new internal_read_localRequest();
case 103:
return new check_objectRequest();
case 50:
return new admin_shutdownRequest();
default :
throw new Exception("String_Node_Str" + Integer.toString(header.getOperationNumber()));
}
}

Fixed version (ground truth):
public static Request createRequest(ONCRPCRequestHeader header) throws Exception {
switch (header.getOperationNumber()) {
case 1:
    return new readRequest();
case 2:
  return new truncateRequest();
case 3:
return new unlinkRequest();
case 4:
return new writeRequest();
case 5:
return new keep_file_openRequest();
case 100:
return new internal_get_gmaxRequest();
case 101:
return new internal_truncateRequest();
case 102:
return new internal_read_localRequest();
case 103:
return new check_objectRequest();
case 50:
return new admin_shutdownRequest();
default :
throw new Exception("String_Node_Str" + Integer.toString(header.getOperationNumber()));
}
}
Program: 113773
Project: 113773
Buggy source:
public static Response createResponse(ONCRPCResponseHeader header) throws Exception {
switch (header.getXID()) {
case 1:
    return new readResponse();
case 2:
  return new truncateResponse();
case 3:
return new unlinkResponse();
case 4:
return new writeResponse();
case 100:
return new internal_get_gmaxResponse();
case 101:
return new internal_truncateResponse();
case 102:
return new internal_read_localResponse();
case 103:
return new check_objectResponse();
case 50:
return new admin_shutdownResponse();
default :
throw new Exception("String_Node_Str" + Integer.toString(header.getXID()));
}
}

Fixed version (ground truth):
public static Response createResponse(ONCRPCResponseHeader header) throws Exception {
switch (header.getXID()) {
case 1:
    return new readResponse();
case 2:
  return new truncateResponse();
case 3:
return new unlinkResponse();
case 4:
return new writeResponse();
case 5:
return new keep_file_openResponse();
case 100:
return new internal_get_gmaxResponse();
case 101:
return new internal_truncateResponse();
case 102:
return new internal_read_localResponse();
case 103:
return new check_objectResponse();
case 50:
return new admin_shutdownResponse();
default :
throw new Exception("String_Node_Str" + Integer.toString(header.getXID()));
}
}
Program: 113774
Project: 113774
Buggy source:
public void start(){
  try {
    rpcServer.start();
    rpcClient.start();
    rpcServer.waitForStartup();
    rpcClient.waitForStartup();
    preprocStage.start();
    delStage.start();
    stStage.start();
    preprocStage.waitForStartup();
    delStage.waitForStartup();
    stStage.waitForStartup();
    heartbeatThread.start();
    heartbeatThread.waitForStartup();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    System.exit(1);
  }
}

Fixed version (ground truth):
public void start(){
  try {
    rpcServer.start();
    rpcClient.start();
    rpcServer.waitForStartup();
    rpcClient.waitForStartup();
    udpCom.start();
    preprocStage.start();
    delStage.start();
    stStage.start();
    udpCom.waitForStartup();
    preprocStage.waitForStartup();
    delStage.waitForStartup();
    stStage.waitForStartup();
    heartbeatThread.start();
    heartbeatThread.waitForStartup();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    System.exit(1);
  }
}
Program: 113776
Project: 113776
Buggy source:
private void initializeOperations(){
  OSDOperation op=new ReadOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new WriteOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new DeleteOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new TruncateOperation(this);
  operations.put(op.getProcedureId(),op);
}

Fixed version (ground truth):
private void initializeOperations(){
  OSDOperation op=new ReadOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new WriteOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new DeleteOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new TruncateOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new KeepFileOpenOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new InternalGetGmaxOperation(this);
  operations.put(op.getProcedureId(),op);
  op=new EventCloseFile(this);
  internalEvents.put(EventCloseFile.class,op);
}
Program: 113777
Project: 113777
Buggy source:
public void shutdown(){
  try {
    heartbeatThread.shutdown();
    heartbeatThread.waitForShutdown();
    UUIDResolver.shutdown();
    rpcServer.shutdown();
    rpcClient.shutdown();
    rpcServer.waitForShutdown();
    rpcClient.waitForShutdown();
    preprocStage.shutdown();
    delStage.shutdown();
    stStage.shutdown();
    preprocStage.waitForShutdown();
    delStage.waitForShutdown();
    stStage.waitForShutdown();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
  }
}

Fixed version (ground truth):
public void shutdown(){
  try {
    heartbeatThread.shutdown();
    heartbeatThread.waitForShutdown();
    UUIDResolver.shutdown();
    rpcServer.shutdown();
    rpcClient.shutdown();
    rpcServer.waitForShutdown();
    rpcClient.waitForShutdown();
    udpCom.shutdown();
    preprocStage.shutdown();
    delStage.shutdown();
    stStage.shutdown();
    udpCom.waitForStartup();
    preprocStage.waitForShutdown();
    delStage.waitForShutdown();
    stStage.waitForShutdown();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
  }
}
Program: 113778
Project: 113778
Buggy source:
public void processRequest(ONCRPCRequest rq){
  final ONCRPCRequestHeader hdr=rq.getRequestHeader();
  if (hdr.getInterfaceVersion() != DIRInterface.getVersion()) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROG_MISMATCH,0,"String_Node_Str"));
    return;
  }
  DIROperation op=registry.get(hdr.getOperationNumber());
  if (op == null) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROC_UNAVAIL,0,"String_Node_Str"));
    return;
  }
  DIRRequest dirRq=new DIRRequest(rq);
  try {
    op.parseRPCMessage(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendGarbageArgs(ex.toString());
    return;
  }
  try {
    op.parseRPCMessage(dirRq);
    numRequests++;
    op.startRequest(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendInternalServerError(ex);
    return;
  }
}

Fixed version (ground truth):
public void processRequest(ONCRPCRequest rq){
  final ONCRPCRequestHeader hdr=rq.getRequestHeader();
  if (hdr.getInterfaceVersion() != DIRInterface.getVersion()) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROG_MISMATCH,0,"String_Node_Str"));
    return;
  }
  DIROperation op=registry.get(hdr.getOperationNumber());
  if (op == null) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROC_UNAVAIL,0,"String_Node_Str"));
    return;
  }
  DIRRequest dirRq=new DIRRequest(rq);
  try {
    op.parseRPCMessage(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendGarbageArgs(ex.toString());
    return;
  }
  try {
    numRequests++;
    op.startRequest(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendInternalServerError(ex);
    return;
  }
}
Program: 113781
Project: 113781
Buggy source:
boolean isLastRequestBuffer(){
  return requestBuffers.size() == requestBufSendCount - 1;
}

Fixed version (ground truth):
boolean isLastRequestBuffer(){
  return requestBuffers.size() == requestBufSendCount + 1;
}
Program: 113783
Project: 113783
Buggy source:
public Object getAttachment() throws InterruptedException {
  if (request != null)   return request.getAttachment();
 else   return null;
}

Fixed version (ground truth):
public Object getAttachment(){
  return this.attachment;
}
Program: 113784
Project: 113784
Buggy source:
public V get() throws ONCRPCException, IOException, InterruptedException {
  waitForResult();
  if ((ioError == null) && (remoteEx == null)) {
    V responseObject=decoder.getResult(request.getResponseFragments().get(0));
    return responseObject;
  }
 else {
    if (ioError != null)     throw ioError;
    throw remoteEx;
  }
}

Fixed version (ground truth):
public V get() throws ONCRPCException, IOException, InterruptedException {
  waitForResult();
  if ((ioError == null) && (remoteEx == null)) {
    V responseObject=decoder.getResult(request.getResponseFragments().get(0));
    return responseObject;
  }
 else {
    if (ioError != null) {
      ioError.fillInStackTrace();
      throw ioError;
    }
    remoteEx.fillInStackTrace();
    throw remoteEx;
  }
}
Program: 113785
Project: 113785
Buggy source:
public void sendResponse(ReusableBuffer serializedResponse){
  ONCRPCBufferWriter writer=new ONCRPCBufferWriter(ONCRPCBufferWriter.BUFF_SIZE);
  responseHeader=new ONCRPCResponseHeader(requestHeader.getXID(),ONCRPCResponseHeader.REPLY_STAT_MSG_ACCEPTED,ONCRPCResponseHeader.ACCEPT_STAT_SUCCESS);
  responseHeader.serialize(writer);
  writer.put(serializedResponse);
  writer.flip();
  System.out.println(writer);
  record.setResponseBuffers(writer.getBuffers());
  record.sendResponse();
}

Fixed version (ground truth):
public void sendResponse(ReusableBuffer serializedResponse){
  ONCRPCBufferWriter writer=new ONCRPCBufferWriter(ONCRPCBufferWriter.BUFF_SIZE);
  responseHeader=new ONCRPCResponseHeader(requestHeader.getXID(),ONCRPCResponseHeader.REPLY_STAT_MSG_ACCEPTED,ONCRPCResponseHeader.ACCEPT_STAT_SUCCESS);
  responseHeader.serialize(writer);
  writer.put(serializedResponse);
  writer.flip();
  record.setResponseBuffers(writer.getBuffers());
  record.sendResponse();
}
Program: 113786
Project: 113786
Buggy source:
public void put(ReusableBuffer otherBuffer){
  currentBuffer++;
  final ReusableBuffer vb=otherBuffer.createViewBuffer();
  vb.position(otherBuffer.limit());
  buffers.add(vb);
}

Fixed version (ground truth):
public void put(ReusableBuffer otherBuffer){
  currentBuffer++;
  otherBuffer.position(otherBuffer.limit());
  buffers.add(otherBuffer);
}
Program: 113787
Project: 113787
Buggy source:
public static ReusableBuffer deserializeSerializableBuffer(ReusableBuffer data){
  final int dataSize=data.getInt();
  if (dataSize == 0)   return BufferPool.allocate(0);
  final ReusableBuffer viewbuf=data.createViewBuffer();
  viewbuf.range(viewbuf.position(),dataSize);
  if (dataSize % 4 > 0) {
    for (int k=0; k < (4 - (dataSize % 4)); k++) {
      data.get();
    }
  }
  return viewbuf;
}

Fixed version (ground truth):
public static ReusableBuffer deserializeSerializableBuffer(ReusableBuffer data){
  final int dataSize=data.getInt();
  if (dataSize == 0)   return BufferPool.allocate(0);
  final ReusableBuffer viewbuf=data.createViewBuffer();
  viewbuf.range(data.position(),dataSize);
  if (dataSize % 4 > 0) {
    for (int k=0; k < (4 - (dataSize % 4)); k++) {
      data.get();
    }
  }
  return viewbuf;
}
Program: 113788
Project: 113788
Buggy source:
public static int serializableBufferLength(ReusableBuffer data){
  int len=data.capacity() + Integer.SIZE / 8;
  if (len % 4 > 0)   len+=4 - (len % 4);
  return len;
}

Fixed version (ground truth):
public static int serializableBufferLength(ReusableBuffer data){
  int len=data.remaining() + Integer.SIZE / 8;
  if (len % 4 > 0)   len+=4 - (len % 4);
  return len;
}
Program: 113789
Project: 113789
Buggy source:
public void processRequest(ONCRPCRequest rq){
  final ONCRPCRequestHeader hdr=rq.getRequestHeader();
  if (hdr.getInterfaceVersion() != DIRInterface.getVersion()) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROG_MISMATCH,0,"String_Node_Str"));
    return;
  }
  DIROperation op=registry.get(hdr.getOperationNumber());
  if (op == null) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROC_UNAVAIL,0,"String_Node_Str"));
    return;
  }
  DIRRequest dirRq=new DIRRequest(rq);
  try {
    op.parseRPCMessage(dirRq);
    numRequests++;
    op.startRequest(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendGarbageArgs(new errnoException(ErrNo.EINVAL,ex.toString()));
    return;
  }
}

Fixed version (ground truth):
public void processRequest(ONCRPCRequest rq){
  final ONCRPCRequestHeader hdr=rq.getRequestHeader();
  if (hdr.getInterfaceVersion() != DIRInterface.getVersion()) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROG_MISMATCH,0,"String_Node_Str"));
    return;
  }
  DIROperation op=registry.get(hdr.getOperationNumber());
  if (op == null) {
    rq.sendProtocolException(new ProtocolException(ONCRPCResponseHeader.ACCEPT_STAT_PROC_UNAVAIL,0,"String_Node_Str"));
    return;
  }
  DIRRequest dirRq=new DIRRequest(rq);
  try {
    op.parseRPCMessage(dirRq);
    numRequests++;
    op.startRequest(dirRq);
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
    rq.sendGarbageArgs(new errnoException(ErrNo.EINVAL,ex.toString(),"String_Node_Str"));
    return;
  }
}
Program: 113791
Project: 113791
Buggy source:
public SimpleRPCServerTest(){
}

Fixed version (ground truth):
public SimpleRPCServerTest(){
  Logging.start(Logging.LEVEL_DEBUG);
  TimeSync.initialize(null,100000,50,"String_Node_Str");
}
Program: 113792
Project: 113792
Buggy source:
public DIRTest() throws IOException {
  config=SetupUtils.createNewDIRConfig();
}

Fixed version (ground truth):
public DIRTest() throws IOException {
  config=SetupUtils.createNewDIRConfig();
  Logging.start(Logging.LEVEL_DEBUG);
  TimeSync.initialize(null,100000,50,"String_Node_Str");
}
Program: 113793
Project: 113793
Buggy source:
public Map<String,Map<String,Object>> getServiceData(){
  String uuid=config.getUUID().toString();
  OperatingSystemMXBean osb=ManagementFactory.getOperatingSystemMXBean();
  String load=String.valueOf((int)(osb.getSystemLoadAverage() * 100 / osb.getAvailableProcessors()));
  long totalRAM=Runtime.getRuntime().maxMemory();
  long usedRAM=Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
  Map<String,Map<String,Object>> map=new HashMap<String,Map<String,Object>>();
  map.put(uuid,RPCClient.generateMap("String_Node_Str","String_Node_Str","String_Node_Str",load,"String_Node_Str",VersionManagement.getSupportedProtVersAsString(),"String_Node_Str",Long.toString(totalRAM),"String_Node_Str",Long.toString(usedRAM),"String_Node_Str",config.getGeoCoordinates()));
  try {
    for (    VolumeInfo vol : volumeManager.getVolumes()) {
      Map<String,Object> dsVolumeInfo=MRCOpHelper.createDSVolumeInfo(vol,osdMonitor,uuid);
      map.put(vol.getId(),dsVolumeInfo);
    }
  }
 catch (  DatabaseException exc) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,exc);
  }
  return map;
}

Fixed version (ground truth):
public Map<String,Map<String,Object>> getServiceData(){
  String uuid=config.getUUID().toString();
  OperatingSystemMXBean osb=ManagementFactory.getOperatingSystemMXBean();
  String load=String.valueOf((int)(osb.getSystemLoadAverage() * 100 / osb.getAvailableProcessors()));
  long totalRAM=Runtime.getRuntime().maxMemory();
  long usedRAM=Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
  Map<String,Map<String,Object>> map=new HashMap<String,Map<String,Object>>();
  map.put(uuid,RPCClient.generateMap("String_Node_Str","String_Node_Str","String_Node_Str",load,"String_Node_Str",VersionManagement.getSupportedProtVersAsString(),"String_Node_Str",Long.toString(totalRAM),"String_Node_Str",Long.toString(usedRAM),"String_Node_Str",config.getGeoCoordinates()));
  try {
    for (    VolumeInfo vol : volumeManager.getVolumes()) {
      Map<String,Object> dsVolumeInfo=MRCHelper.createDSVolumeInfo(vol,osdMonitor,uuid);
      map.put(vol.getId(),dsVolumeInfo);
    }
  }
 catch (  DatabaseException exc) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,exc);
  }
  return map;
}
Program: 113808
Project: 113808
Buggy source:
@Override public void run(){
  try {
    notifyStarted();
    while (!quit) {
      final ONCRPCRequest rq=queue.take();
      processRequest(rq);
    }
  }
 catch (  InterruptedException ex) {
    quit=true;
  }
catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    notifyCrashed(ex);
  }
  notifyStopped();
}

Fixed version (ground truth):
@Override public void run(){
  try {
    notifyStarted();
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
    while (!quit) {
      final ONCRPCRequest rq=queue.take();
      processRequest(rq);
    }
  }
 catch (  InterruptedException ex) {
    quit=true;
  }
catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    notifyCrashed(ex);
  }
  notifyStopped();
}
Program: 113809
Project: 113809
Buggy source:
@Override public void startRequest(DIRRequest rq){
  try {
    final service_registerRequest request=(service_registerRequest)rq.getRequestMessage();
    final ServiceRegistry reg=request.getService();
    byte[] data=database.directLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_SERVREG,reg.getUuid().getBytes());
    long currentVersion=0;
    if (data != null) {
      ServiceRegistry dbData=new ServiceRegistry();
      ReusableBuffer buf=ReusableBuffer.wrap(data);
      dbData.deserialize(buf);
      currentVersion=dbData.getVersion();
    }
    if (reg.getVersion() != currentVersion) {
      rq.sendException(new ConcurrentModificationException());
      return;
    }
    currentVersion++;
    reg.setVersion(currentVersion);
    ONCRPCBufferWriter writer=new ONCRPCBufferWriter(reg.calculateSize());
    reg.serialize(writer);
    byte[] newData=writer.getBuffers().get(0).array();
    BabuDBInsertGroup ig=database.createInsertGroup(DIRRequestDispatcher.DB_NAME);
    ig.addInsert(DIRRequestDispatcher.INDEX_ID_SERVREG,reg.getUuid().getBytes(),newData);
    database.directInsert(ig);
    service_registerResponse response=new service_registerResponse(currentVersion);
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
}

Fixed version (ground truth):
@Override public void startRequest(DIRRequest rq){
  try {
    final service_registerRequest request=(service_registerRequest)rq.getRequestMessage();
    final ServiceRegistry reg=request.getService();
    byte[] data=database.directLookup(DIRRequestDispatcher.DB_NAME,DIRRequestDispatcher.INDEX_ID_SERVREG,reg.getUuid().getBytes());
    long currentVersion=0;
    if (data != null) {
      ServiceRegistry dbData=new ServiceRegistry();
      ReusableBuffer buf=ReusableBuffer.wrap(data);
      dbData.deserialize(buf);
      currentVersion=dbData.getVersion();
    }
    if (reg.getVersion() != currentVersion) {
      rq.sendException(new ConcurrentModificationException());
      return;
    }
    currentVersion++;
    reg.setVersion(currentVersion);
    reg.getData().add(new KeyValuePair("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000l)));
    ONCRPCBufferWriter writer=new ONCRPCBufferWriter(reg.calculateSize());
    reg.serialize(writer);
    byte[] newData=writer.getBuffers().get(0).array();
    BabuDBInsertGroup ig=database.createInsertGroup(DIRRequestDispatcher.DB_NAME);
    ig.addInsert(DIRRequestDispatcher.INDEX_ID_SERVREG,reg.getUuid().getBytes(),newData);
    database.directInsert(ig);
    service_registerResponse response=new service_registerResponse(currentVersion);
    rq.sendSuccess(response);
  }
 catch (  BabuDBException ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex);
    rq.sendInternalServerError();
  }
catch (  Throwable th) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,th);
    rq.sendInternalServerError();
  }
}
Program: 113810
Project: 113810
Buggy source:
public RPCNIOSocketClient(SSLOptions sslOptions,int requestTimeout,int connectionTimeout) throws IOException {
  super("String_Node_Str");
  if (requestTimeout >= connectionTimeout - TIMEOUT_GRANULARITY * 2) {
    throw new IllegalArgumentException("String_Node_Str" + TIMEOUT_GRANULARITY * 2 + "String_Node_Str");
  }
  this.requestTimeout=requestTimeout;
  this.connectionTimeout=connectionTimeout;
  connections=new HashMap();
  selector=Selector.open();
  this.sslOptions=sslOptions;
  quit=false;
  transactionId=new AtomicInteger(1);
}

Fixed version (ground truth):
public RPCNIOSocketClient(SSLOptions sslOptions,int requestTimeout,int connectionTimeout) throws IOException {
  super("String_Node_Str");
  if (requestTimeout >= connectionTimeout - TIMEOUT_GRANULARITY * 2) {
    throw new IllegalArgumentException("String_Node_Str" + TIMEOUT_GRANULARITY * 2 + "String_Node_Str");
  }
  this.requestTimeout=requestTimeout;
  this.connectionTimeout=connectionTimeout;
  connections=new HashMap();
  selector=Selector.open();
  this.sslOptions=sslOptions;
  quit=false;
  transactionId=new AtomicInteger(1);
  toBeEstablished=new ConcurrentLinkedQueue<ServerConnection>();
}
Program: 113812
Project: 113812
Buggy source:
private void connectConnection(SelectionKey key){
  final ServerConnection con=(ServerConnection)key.attachment();
  final ChannelIO channel=con.getChannel();
  try {
    if (channel.isConnectionPending()) {
      channel.finishConnect();
    }
synchronized (con) {
      if (!con.getSendQueue().isEmpty()) {
        key.interestOps(SelectionKey.OP_WRITE | SelectionKey.OP_READ);
      }
    }
    con.connected();
  }
 catch (  IOException ex) {
    con.connectFailed();
    closeConnection(key,new IOException("String_Node_Str",ex));
  }
}

Fixed version (ground truth):
private void connectConnection(SelectionKey key){
  final ServerConnection con=(ServerConnection)key.attachment();
  final ChannelIO channel=con.getChannel();
  try {
    if (channel.isConnectionPending()) {
      channel.finishConnect();
    }
synchronized (con) {
      if (!con.getSendQueue().isEmpty()) {
        key.interestOps(SelectionKey.OP_WRITE | SelectionKey.OP_READ);
      }
    }
    con.connected();
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.getChannel().socket().getLocalSocketAddress() + "String_Node_Str"+ con.getEndpoint());
  }
 catch (  IOException ex) {
    con.connectFailed();
    closeConnection(key,new IOException("String_Node_Str",ex));
  }
}
Program: 113813
Project: 113813
Buggy source:
public void run(){
  notifyStarted();
  lastCheck=System.currentTimeMillis();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  while (!quit) {
    int numKeys=0;
    try {
      numKeys=selector.select(TIMEOUT_GRANULARITY);
    }
 catch (    CancelledKeyException ex) {
    }
catch (    IOException ex) {
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + ex);
      continue;
    }
    if (numKeys > 0) {
      Set<SelectionKey> keys=selector.selectedKeys();
      Iterator<SelectionKey> iter=keys.iterator();
      while (iter.hasNext()) {
        try {
          SelectionKey key=iter.next();
          iter.remove();
          if (key.isConnectable()) {
            connectConnection(key);
          }
          if (key.isReadable()) {
            readConnection(key);
          }
          if (key.isWritable()) {
            writeConnection(key);
          }
        }
 catch (        CancelledKeyException ex) {
          continue;
        }
      }
    }
    checkForTimers();
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  notifyStopped();
}

Fixed version (ground truth):
public void run(){
  notifyStarted();
  lastCheck=System.currentTimeMillis();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  while (!quit) {
    int numKeys=0;
    try {
      numKeys=selector.select(TIMEOUT_GRANULARITY);
    }
 catch (    CancelledKeyException ex) {
    }
catch (    IOException ex) {
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + ex);
      continue;
    }
    if (!toBeEstablished.isEmpty()) {
      while (true) {
        ServerConnection con=toBeEstablished.poll();
        if (con == null)         break;
        try {
          con.getChannel().register(selector,SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE | SelectionKey.OP_READ,con);
        }
 catch (        ClosedChannelException ex) {
          closeConnection(con.getChannel().keyFor(selector),ex);
        }
      }
      toBeEstablished.clear();
    }
    if (numKeys > 0) {
      Set<SelectionKey> keys=selector.selectedKeys();
      Iterator<SelectionKey> iter=keys.iterator();
      while (iter.hasNext()) {
        try {
          SelectionKey key=iter.next();
          iter.remove();
          if (key.isConnectable()) {
            connectConnection(key);
          }
          if (key.isReadable()) {
            readConnection(key);
          }
          if (key.isWritable()) {
            writeConnection(key);
          }
        }
 catch (        CancelledKeyException ex) {
          continue;
        }
      }
    }
    checkForTimers();
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  notifyStopped();
}
Program: 113814
Project: 113814
Buggy source:
private void sendRequest(InetSocketAddress server,ONCRPCRequest request){
  ServerConnection con=null;
synchronized (connections) {
    con=connections.get(server);
    if (con == null) {
      con=new ServerConnection(server);
      connections.put(server,con);
    }
  }
synchronized (con) {
    boolean isEmpty=con.getSendQueue().isEmpty();
    request.queued();
    con.useConnection();
    con.getSendQueue().add(request);
    if (!con.isConnected()) {
      establishConnection(server,con);
    }
 else {
      if (isEmpty) {
        final SelectionKey key=con.getChannel().keyFor(selector);
        key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
      }
    }
  }
}

Fixed version (ground truth):
private void sendRequest(InetSocketAddress server,ONCRPCRequest request){
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + request + "String_Node_Str"+ transactionId.get());
  ServerConnection con=null;
synchronized (connections) {
    con=connections.get(server);
    if (con == null) {
      con=new ServerConnection(server);
      connections.put(server,con);
    }
  }
synchronized (con) {
    boolean isEmpty=con.getSendQueue().isEmpty();
    request.queued();
    con.useConnection();
    con.getSendQueue().add(request);
    if (!con.isConnected()) {
      establishConnection(server,con);
    }
 else {
      if (isEmpty) {
        final SelectionKey key=con.getChannel().keyFor(selector);
        key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
      }
    }
  }
}
Program: 113815
Project: 113815
Buggy source:
private void establishConnection(InetSocketAddress server,ServerConnection con){
  if (con.canReconnect()) {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
    }
    ChannelIO channel;
    try {
      if (sslOptions == null) {
        channel=new ChannelIO(SocketChannel.open());
      }
 else {
        channel=new SSLChannelIO(SocketChannel.open(),sslOptions,true);
      }
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(true);
      channel.socket().setReceiveBufferSize(256 * 1024);
      channel.connect(server);
      con.setChannel(channel);
      channel.register(selector,SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE | SelectionKey.OP_READ,con);
    }
 catch (    IOException ex) {
      if (Logging.isDebug()) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.getEndpoint());
      }
      con.connectFailed();
      for (      ONCRPCRequest rq : con.getSendQueue()) {
        rq.getListener().requestFailed(rq,new IOException("String_Node_Str",ex));
      }
      con.getSendQueue().clear();
    }
  }
 else {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.getEndpoint());
    }
synchronized (con) {
      for (      ONCRPCRequest rq : con.getSendQueue()) {
        rq.getListener().requestFailed(rq,new IOException("String_Node_Str"));
      }
      con.getSendQueue().clear();
    }
  }
}

Fixed version (ground truth):
private void establishConnection(InetSocketAddress server,ServerConnection con){
  if (con.canReconnect()) {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
    }
    ChannelIO channel;
    try {
      if (sslOptions == null) {
        channel=new ChannelIO(SocketChannel.open());
      }
 else {
        channel=new SSLChannelIO(SocketChannel.open(),sslOptions,true);
      }
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(true);
      channel.socket().setReceiveBufferSize(256 * 1024);
      channel.connect(server);
      con.setChannel(channel);
      toBeEstablished.add(con);
      selector.wakeup();
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
    }
 catch (    IOException ex) {
      if (Logging.isDebug()) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.getEndpoint());
      }
      con.connectFailed();
      for (      ONCRPCRequest rq : con.getSendQueue()) {
        rq.getListener().requestFailed(rq,new IOException("String_Node_Str",ex));
      }
      con.getSendQueue().clear();
    }
  }
 else {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.getEndpoint());
    }
synchronized (con) {
      for (      ONCRPCRequest rq : con.getSendQueue()) {
        rq.getListener().requestFailed(rq,new IOException("String_Node_Str"));
      }
      con.getSendQueue().clear();
    }
  }
}
Program: 113816
Project: 113816
Buggy source:
public void freeBuffers(){
  request.freeBuffers();
}

Fixed version (ground truth):
public void freeBuffers(){
  if (request != null)   request.freeBuffers();
}
Program: 113817
Project: 113817
Buggy source:
public ClientConnection(ChannelIO channel){
  this.channel=channel;
  this.openRequests=new AtomicInteger(0);
  this.pendingResponses=new ConcurrentLinkedQueue();
  this.connectionClosed=false;
  this.receiveFragHdr=ByteBuffer.allocate(ONCRPCRecordFragmentHeader.getFragmentHeaderSize());
  this.sendFragHdr=ByteBuffer.allocate(ONCRPCRecordFragmentHeader.getFragmentHeaderSize());
  this.sendFragHdr.position(sendFragHdr.capacity());
  this.sendingFragmentHeader=true;
}

Fixed version (ground truth):
public ClientConnection(ChannelIO channel){
  this.channel=channel;
  this.openRequests=new AtomicInteger(0);
  this.pendingResponses=new ConcurrentLinkedQueue();
  this.connectionClosed=false;
  this.receiveFragHdr=ByteBuffer.allocate(ONCRPCRecordFragmentHeader.getFragmentHeaderSize());
  this.sendFragHdr=ByteBuffer.allocate(ONCRPCRecordFragmentHeader.getFragmentHeaderSize());
  this.sendFragHdr.position(sendFragHdr.capacity());
  this.sendingFragmentHeader=true;
  try {
    this.clientAddress=channel.socket().getRemoteSocketAddress();
  }
 catch (  Exception ex) {
  }
}
Program: 113819
Project: 113819
Buggy source:
/** 
 * sends a response.
 * @param request the request
 */
public void sendResponse(ONCRPCRecord request){
  assert(request.getResponseBuffers() != null);
  final ClientConnection connection=request.getConnection();
  if (!connection.isConnectionClosed()) {
synchronized (connection) {
      boolean isEmpty=connection.getPendingResponses().isEmpty();
      connection.addPendingResponse(request);
      if (isEmpty) {
        SelectionKey key=connection.getChannel().keyFor(selector);
        key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
      }
    }
    selector.wakeup();
  }
 else {
    request.freeBuffers();
  }
}

Fixed version (ground truth):
/** 
 * sends a response.
 * @param request the request
 */
public void sendResponse(ONCRPCRecord request){
  assert(request.getResponseBuffers() != null);
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
  final ClientConnection connection=request.getConnection();
  if (!connection.isConnectionClosed()) {
synchronized (connection) {
      boolean isEmpty=connection.getPendingResponses().isEmpty();
      connection.addPendingResponse(request);
      if (isEmpty) {
        SelectionKey key=connection.getChannel().keyFor(selector);
        key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
      }
    }
    selector.wakeup();
  }
 else {
    request.freeBuffers();
  }
}
Program: 113820
Project: 113820
Buggy source:
public void shutdown() throws Exception {
  pinkyStage.shutdown();
  pinkyStage.waitForShutdown();
  heartbeatThread.shutdown();
  osdMonitor.shutdown();
  osdMonitor.waitForShutdown();
  procStage.shutdown();
  procStage.waitForShutdown();
  UUIDResolver.shutdown();
  speedyStage.shutdown();
  speedyStage.waitForShutdown();
  volumeManager.shutdown();
  TimeSync.getInstance().shutdown();
  rpcClient.shutdown();
  rpcClient.waitForShutdown();
}

Fixed version (ground truth):
public void shutdown() throws Exception {
  pinkyStage.shutdown();
  pinkyStage.waitForShutdown();
  rpcClient.shutdown();
  rpcClient.waitForShutdown();
  heartbeatThread.shutdown();
  osdMonitor.shutdown();
  osdMonitor.waitForShutdown();
  procStage.shutdown();
  procStage.waitForShutdown();
  UUIDResolver.shutdown();
  speedyStage.shutdown();
  speedyStage.waitForShutdown();
  volumeManager.shutdown();
  TimeSync.getInstance().shutdown();
}