nus-yam/ex-repair huggingface dataset:
Program: 87230
Project: 87230
Buggy source:
@Test public void testGetDispatchProc(){
}

Fixed version (ground truth):
@Test public void testGetDispatchProc(){
  DispatchResult result=new DispatchResult(node);
  result.isTest=true;
  nodeDispatcher.dispatch(result,node);
  for (  DispatchProc proc : result.procs) {
    DispatchProc dbProc=dispatchDao.getDispatchProc(proc.getProcId());
    assertEquals(proc.getProcId(),dbProc.getProcId());
    assertEquals(proc.getJobId(),dbProc.getJobId());
    assertEquals(proc.getNodeId(),dbProc.getNodeId());
    assertEquals(proc.getTaskId(),dbProc.getTaskId());
    assertEquals(proc.getIdleCores(),proc.getIdleCores());
    assertEquals(proc.getIdleRam(),proc.getIdleRam());
  }
}
Program: 87231
Project: 87231
Buggy source:
@Override public DispatchProc create(DispatchNode node,DispatchableTask task){
  DispatchProc proc=new DispatchProc();
  proc.setProcId(UUID.randomUUID());
  proc.setJobId(task.jobId);
  proc.setTaskId(task.taskId);
  proc.setHostname(node.getName());
  proc.setNodeId(node.getNodeId());
  proc.setAllocated(true);
  proc.setTags(node.getTags());
  proc.setCores(task.minCores);
  proc.setMemory(task.minRam);
  jdbc.update(INSERT,proc.getProcId(),node.getNodeId(),task.jobId,task.taskId,task.minCores,task.minRam);
  return proc;
}

Fixed version (ground truth):
@Override public DispatchProc create(DispatchNode node,DispatchableTask task){
  DispatchProc proc=new DispatchProc();
  proc.setProcId(UUID.randomUUID());
  proc.setJobId(task.jobId);
  proc.setTaskId(task.taskId);
  proc.setHostname(node.getName());
  proc.setNodeId(node.getNodeId());
  proc.setAllocated(true);
  proc.setTags(node.getTags());
  proc.setCores(task.minCores);
  proc.setMemory(task.minRam);
  jdbc.update(INSERT,proc.getProcId(),node.getNodeId(),task.taskId,task.jobId,task.minCores,task.minRam);
  return proc;
}
Program: 87232
Project: 87232
Buggy source:
@Override public Quota getQuota(Proc proc){
  return jdbc.queryForObject(GET_BY_TASK,MAPPER,proc.getTaskId(),proc.getNodeId());
}

Fixed version (ground truth):
@Override public Quota getQuota(Proc proc){
  return jdbc.queryForObject(GET_BY_PROC,MAPPER,proc.getJobId(),proc.getNodeId());
}
Program: 87233
Project: 87233
Buggy source:
@Override public boolean allocateResources(Quota quota,int cores){
  return jdbc.update(ALLOCATE_RESOURCE,cores,quota.getQuotaId()) == 1;
}

Fixed version (ground truth):
@Override public boolean allocateResources(Quota quota,int cores){
  Preconditions.checkNotNull(quota);
  return jdbc.update(ALLOCATE_RESOURCE,cores,quota.getQuotaId(),cores) == 1;
}
Program: 87234
Project: 87234
Buggy source:
public void taskComplete(RunTaskResult result){
  Task task=jobService.getTask(result.taskId);
  DispatchJob job=frontEndDispatcher.getJob(task.getJobId());
  DispatchProc proc=dispatchService.getDispatchProc(result.procId);
  TaskState newState;
  if (result.exitStatus == 0) {
    newState=TaskState.SUCCEEDED;
  }
 else {
    newState=TaskState.DEAD;
  }
  logger.info("String_Node_Str",new Object[]{proc.getHostname(),proc.getTaskName(),result.exitStatus});
  logger.info("String_Node_Str",newState.toString());
  if (dispatchService.stopTask(task,newState)) {
    dispatchService.unassignProc(proc);
    jobStateManager.satisfyDependsOn(task);
    final Layer layer=new LayerE(task);
    if (jobService.isLayerComplete(layer)) {
      jobStateManager.satisfyDependsOn(layer);
    }
  }
 else {
    logger.warn("String_Node_Str",proc.getTaskName());
    return;
  }
  if (jobService.isJobPaused(job)) {
    dispatchService.unbookProc(proc,"String_Node_Str" + job.getJobId());
  }
 else   if (jobService.isFinished(job)) {
    dispatchService.unbookProc(proc,"String_Node_Str" + job.getJobId());
    jobStateManager.shutdown(job);
  }
 else {
    dispatchPool.execute(new DispatchProcToJob(proc,job,frontEndDispatcher));
  }
}

Fixed version (ground truth):
public void taskComplete(RunTaskResult result){
  Task task=jobService.getTask(result.taskId);
  DispatchJob job=frontEndDispatcher.getJob(task.getJobId());
  DispatchProc proc=dispatchService.getDispatchProc(result.procId);
  TaskState newState;
  if (result.exitStatus == 0) {
    newState=TaskState.SUCCEEDED;
  }
 else {
    newState=TaskState.DEAD;
  }
  logger.info("String_Node_Str",new Object[]{proc.getHostname(),proc.getTaskName(),result.exitStatus});
  logger.info("String_Node_Str",newState.toString());
  if (dispatchService.stopTask(task,newState)) {
    dispatchService.unassignProc(proc);
    if (newState.equals(TaskState.SUCCEEDED)) {
      jobStateManager.satisfyDependsOn(task);
      final Layer layer=new LayerE(task);
      if (jobService.isLayerComplete(layer)) {
        jobStateManager.satisfyDependsOn(layer);
      }
    }
  }
 else {
    logger.warn("String_Node_Str",proc.getTaskName());
    return;
  }
  if (jobService.isJobPaused(job)) {
    dispatchService.unbookProc(proc,"String_Node_Str" + job.getJobId());
  }
 else   if (jobService.isFinished(job)) {
    dispatchService.unbookProc(proc,"String_Node_Str" + job.getJobId());
    jobStateManager.shutdownJob(job);
  }
 else {
    dispatchPool.execute(new DispatchProcToJob(proc,job,frontEndDispatcher));
  }
}
Program: 87235
Project: 87235
Buggy source:
@Override public DispatchProc createProc(DispatchNode node,DispatchTask task){
  final Quota quota=quotaDao.getQuota(node,task);
  final DispatchProc proc=new DispatchProc();
  proc.setTaskId(task.getTaskId());
  proc.setNodeId(node.getNodeId());
  proc.setQuotaId(quota.getQuotaId());
  proc.setCores(task.getMinCores());
  proc.setTaskName(task.getName());
  proc.setHostname(node.getName());
  proc.setJobId(task.getJobId());
  proc.setLayerId(task.getLayerId());
  proc.setTags(task.getTags());
  procDao.create(proc);
  nodeDao.allocateResources(node,task.getMinCores(),task.getMinMemory());
  quotaDao.allocateResources(quota,task.getMinCores());
  dispatchDao.addToDispatchTotals(proc);
  node.decrement(task.getMinCores(),task.getMinMemory());
  return proc;
}

Fixed version (ground truth):
@Override public DispatchProc createProc(DispatchNode node,DispatchTask task){
  final Quota quota=quotaDao.getQuota(node,task);
  final DispatchProc proc=new DispatchProc();
  proc.setTaskId(task.getTaskId());
  proc.setNodeId(node.getNodeId());
  proc.setQuotaId(quota.getQuotaId());
  proc.setCores(task.getMinCores());
  proc.setMemory(task.getMinMemory());
  proc.setTaskName(task.getName());
  proc.setHostname(node.getName());
  proc.setJobId(task.getJobId());
  proc.setLayerId(task.getLayerId());
  proc.setTags(task.getTags());
  procDao.create(proc);
  nodeDao.allocateResources(node,task.getMinCores(),task.getMinMemory());
  quotaDao.allocateResources(quota,task.getMinCores());
  dispatchDao.addToDispatchTotals(proc);
  node.decrement(task.getMinCores(),task.getMinMemory());
  return proc;
}
Program: 87236
Project: 87236
Buggy source:
@Override public void unbookProc(DispatchProc proc,String why){
  if (proc == null) {
    logger.info("String_Node_Str");
    return;
  }
  if (!proc.isAllocated()) {
    logger.warn("String_Node_Str",proc.getProcId(),why);
    return;
  }
  logger.info("String_Node_Str",proc.getProcId(),why);
  if (procDao.delete(proc)) {
    logger.info("String_Node_Str",proc.getProcId());
    final Quota quota=quotaDao.get(proc.getQuotaId());
    final Node node=nodeDao.get(proc.getNodeId());
    nodeDao.freeResources(node,proc.getCores(),proc.getMemory());
    quotaDao.freeResources(quota,proc.getCores());
    dispatchDao.subtractFromDispatchTotals(proc);
    proc.setAllocated(false);
    eventManager.post(new JobUnbookedEvent(proc));
  }
 else {
    logger.warn("String_Node_Str",proc.getProcId());
  }
}

Fixed version (ground truth):
@Override public void unbookProc(DispatchProc proc,String why){
  if (proc == null) {
    logger.info("String_Node_Str");
    return;
  }
  if (!proc.isAllocated()) {
    logger.warn("String_Node_Str",proc.getProcId(),why);
    return;
  }
  logger.info("String_Node_Str",proc.getProcId(),why);
  if (procDao.delete(proc)) {
    logger.info("String_Node_Str",proc.getProcId());
    logger.info("String_Node_Str",proc.getCores(),proc.getMemory());
    final Quota quota=quotaDao.get(proc.getQuotaId());
    final Node node=nodeDao.get(proc.getNodeId());
    nodeDao.freeResources(node,proc.getCores(),proc.getMemory());
    quotaDao.freeResources(quota,proc.getCores());
    dispatchDao.subtractFromDispatchTotals(proc);
    proc.setAllocated(false);
    eventManager.post(new JobUnbookedEvent(proc));
  }
 else {
    logger.warn("String_Node_Str",proc.getProcId());
  }
}
Program: 87237
Project: 87237
Buggy source:
public boolean killJob(Job job,String reason){
  final boolean killResult=jobService.shutdown(job);
  if (killResult) {
    processManager.killProcs(job,reason);
  }
  return killResult;
}

Fixed version (ground truth):
public boolean killJob(Job job,String reason){
  final boolean killResult=shutdownJob(job);
  if (killResult) {
    processManager.killProcs(job,reason);
  }
  return killResult;
}
Program: 87238
Project: 87238
Buggy source:
@Override public List<NodeT> getNodes(NodeFilterT filter) throws PlowException, TException {
  return null;
}

Fixed version (ground truth):
@Override public List<NodeT> getNodes(NodeFilterT filter) throws PlowException, TException {
  return thriftNodeDao.getNodes(filter);
}
Program: 87239
Project: 87239
Buggy source:
@Test public void testGetTasks(){
  JobSpecT spec=getTestJobSpec();
  jobService.launch(spec);
  @SuppressWarnings("String_Node_Str") UUID id=simpleJdbcTemplate.queryForObject("String_Node_Str",UUID.class);
  List<TaskT> task=thriftTaskDao.getTasks(id);
  assertTrue(task.size() > 0);
}

Fixed version (ground truth):
@Test public void testGetTasks(){
  JobSpecT spec=getTestJobSpec();
  JobLaunchEvent event=jobService.launch(spec);
  TaskFilterT filter=new TaskFilterT();
  filter.jobId=event.getJob().getJobId().toString();
  List<TaskT> task=thriftTaskDao.getTasks(filter);
  assertTrue(task.size() > 0);
}
Program: 87240
Project: 87240
Buggy source:
@Subscribe public void handleJobUnbookedEvent(JobUnbookedEvent event){
  DispatchJob job=jobIndex.get(event.getProc().getJobId());
  if (job == null) {
    return;
  }
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.decrementCores(proc.getCores());
  }
  DispatchFolder folder=folderIndex.get(job.getFolderId());
synchronized (folder) {
    folder.decrementCores(proc.getCores());
  }
}

Fixed version (ground truth):
@Subscribe public void handleJobUnbookedEvent(JobUnbookedEvent event){
  final DispatchJob job=jobIndex.get(event.getProc().getJobId());
  if (job == null) {
    logger.info("String_Node_Str");
    return;
  }
  final DispatchFolder folder=folderIndex.get(job.getFolderId());
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.decrementCores(proc.getCores());
  }
synchronized (folder) {
    folder.decrementCores(proc.getCores());
  }
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
}
Program: 87241
Project: 87241
Buggy source:
@Subscribe public void handleJobBookedEvent(JobBookedEvent event){
  DispatchJob job=jobIndex.get(event.getTask().getJobId());
  if (job == null) {
    return;
  }
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.incrementCores(proc.getCores());
  }
  DispatchFolder folder=folderIndex.get(job.getFolderId());
synchronized (folder) {
    folder.incrementCores(proc.getCores());
  }
}

Fixed version (ground truth):
@Subscribe public void handleJobBookedEvent(JobBookedEvent event){
  DispatchJob job=jobIndex.get(event.getTask().getJobId());
  if (job == null) {
    logger.info("String_Node_Str");
    return;
  }
  final DispatchFolder folder=folderIndex.get(job.getFolderId());
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.incrementCores(proc.getCores());
  }
synchronized (folder) {
    folder.incrementCores(proc.getCores());
  }
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
}
Program: 87242
Project: 87242
Buggy source:
private void addNewJobs(){
  int count=0;
  while (true) {
    DispatchJob job=addJobs.poll();
    if (job == null) {
      logger.info("String_Node_Str");
      break;
    }
    count++;
    if (!activeJobs.containsKey(job.getProjectId())) {
      activeJobs.put(job.getProjectId(),new ArrayList<DispatchJob>());
    }
    activeJobs.get(job.getProjectId()).add(job);
  }
  logger.info("String_Node_Str" + count + "String_Node_Str");
}

Fixed version (ground truth):
private void addNewJobs(){
  int count=0;
  while (true) {
    DispatchJob job=addJobs.poll();
    if (job == null) {
      break;
    }
 else {
      count++;
      if (!activeJobs.containsKey(job.getProjectId())) {
        activeJobs.put(job.getProjectId(),new ArrayList<DispatchJob>());
      }
      activeJobs.get(job.getProjectId()).add(job);
    }
  }
  logger.info("String_Node_Str" + count + "String_Node_Str");
}
Program: 87243
Project: 87243
Buggy source:
@Subscribe public void handleJobUnbookedEvent(JobUnbookedEvent event){
  final DispatchJob job=jobIndex.get(event.getProc().getJobId());
  if (job == null) {
    logger.info("String_Node_Str");
    return;
  }
  final DispatchFolder folder=folderIndex.get(job.getFolderId());
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.decrementCores(proc.getCores());
  }
synchronized (folder) {
    folder.decrementCores(proc.getCores());
  }
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
}

Fixed version (ground truth):
@Subscribe public void handleJobUnbookedEvent(JobUnbookedEvent event){
  DispatchJob job=jobIndex.get(event.getProc().getJobId());
  if (job == null) {
    return;
  }
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.decrementCores(proc.getCores());
  }
  DispatchFolder folder=folderIndex.get(job.getFolderId());
synchronized (folder) {
    folder.decrementCores(proc.getCores());
  }
}
Program: 87244
Project: 87244
Buggy source:
@Subscribe public void handleJobBookedEvent(JobBookedEvent event){
  DispatchJob job=jobIndex.get(event.getTask().getJobId());
  if (job == null) {
    logger.info("String_Node_Str");
    return;
  }
  final DispatchFolder folder=folderIndex.get(job.getFolderId());
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.incrementCores(proc.getCores());
  }
synchronized (folder) {
    folder.incrementCores(proc.getCores());
  }
  logger.info("String_Node_Str",job.getRunCores(),folder.getRunCores());
}

Fixed version (ground truth):
@Subscribe public void handleJobBookedEvent(JobBookedEvent event){
  DispatchJob job=jobIndex.get(event.getTask().getJobId());
  if (job == null) {
    return;
  }
  DispatchProc proc=event.getProc();
synchronized (job) {
    job.incrementCores(proc.getCores());
  }
  DispatchFolder folder=folderIndex.get(job.getFolderId());
synchronized (folder) {
    folder.incrementCores(proc.getCores());
  }
}
Program: 87245
Project: 87245
Buggy source:
public void taskComplete(RunTaskResult result){
  Task task=jobService.getTask(result.taskId);
  DispatchJob job=frontEndDispatcher.getJob(task.getJobId());
  DispatchProc proc=dispatchService.getDispatchProc(result.procId);
  TaskState newState;
  if (result.exitStatus == 0) {
    newState=TaskState.SUCCEEDED;
  }
 else {
    newState=TaskState.DEAD;
  }
  logger.info("String_Node_Str",new Object[]{proc.getNodeName(),proc.getTaskName(),result.exitStatus});
  logger.info("String_Node_Str",newState.toString());
  if (!jobService.stopTask(task,newState)) {
    logger.warn("String_Node_Str",proc.getTaskName());
    return;
  }
 else {
    dispatchService.unassignProc(proc);
  }
  if (!jobService.hasPendingFrames(job)) {
    jobService.shutdown(job);
    return;
  }
  dispatchPool.execute(new DispatchProcToJob(proc,job,frontEndDispatcher));
}

Fixed version (ground truth):
public void taskComplete(RunTaskResult result){
  Task task=jobService.getTask(result.taskId);
  DispatchJob job=frontEndDispatcher.getJob(task.getJobId());
  DispatchProc proc=dispatchService.getDispatchProc(result.procId);
  TaskState newState;
  if (result.exitStatus == 0) {
    newState=TaskState.SUCCEEDED;
  }
 else {
    newState=TaskState.DEAD;
  }
  logger.info("String_Node_Str",new Object[]{proc.getNodeName(),proc.getTaskName(),result.exitStatus});
  logger.info("String_Node_Str",newState.toString());
  if (!jobService.stopTask(task,newState)) {
    logger.warn("String_Node_Str",proc.getTaskName());
    return;
  }
 else {
    dispatchService.unassignProc(proc);
  }
  if (!jobService.hasPendingFrames(job)) {
    jobService.shutdown(job);
    dispatchService.unbookProc(proc);
  }
  dispatchPool.execute(new DispatchProcToJob(proc,job,frontEndDispatcher));
}
Program: 87246
Project: 87246
Buggy source:
public void book(DispatchNode node,DispatchTask task){
  if (!dispatchService.reserveTask(task)) {
    logger.warn("String_Node_Str",task.getName());
    return;
  }
  DispatchProc proc=null;
  try {
    proc=dispatchService.allocateDispatchProc(node,task);
    if (jobService.startTask(task,proc)) {
      dispatchSupport.runRndTask(task,proc);
    }
  }
 catch (  DispatchProcAllocationException e) {
    logger.warn("String_Node_Str",new Object[]{task.getMinCores(),task.getMinMemory(),node.getName()});
    node.setDispatchable(false);
  }
catch (  RndClientExecuteException e) {
    logger.warn("String_Node_Str" + node.getName());
    jobService.unreserveTask(task);
    dispatchService.cleanupFailedDispatch(proc);
    node.setDispatchable(false);
  }
catch (  Exception e) {
    logger.warn("String_Node_Str" + e);
    jobService.unreserveTask(task);
    dispatchService.cleanupFailedDispatch(proc);
    node.setDispatchable(false);
  }
}

Fixed version (ground truth):
public void book(DispatchNode node,DispatchTask task){
  if (!dispatchService.reserveTask(task)) {
    logger.warn("String_Node_Str",task.getName());
    return;
  }
  DispatchProc proc=null;
  try {
    proc=dispatchService.allocateDispatchProc(node,task);
    if (jobService.startTask(task,proc)) {
      dispatchSupport.runRndTask(task,proc);
    }
  }
 catch (  DispatchProcAllocationException e) {
    logger.warn("String_Node_Str",new Object[]{task.getMinCores(),task.getMinMemory(),node.getName()});
    node.setDispatchable(false);
  }
catch (  RndClientExecuteException e) {
    logger.warn("String_Node_Str" + node.getName());
    jobService.unreserveTask(task);
    dispatchService.unbookProc(proc);
    node.setDispatchable(false);
  }
catch (  Exception e) {
    logger.warn("String_Node_Str" + e);
    jobService.unreserveTask(task);
    dispatchService.unbookProc(proc);
    node.setDispatchable(false);
  }
}
Program: 87247
Project: 87247
Buggy source:
public boolean dispatch(DispatchProc proc,DispatchTask task){
  if (!dispatchService.reserveTask(task)) {
    logger.warn("String_Node_Str",task.getName());
    return false;
  }
  try {
    dispatchService.assignProc(proc,task);
    if (jobService.startTask(task,proc)) {
      dispatchSupport.runRndTask(task,proc);
      return true;
    }
  }
 catch (  RndClientExecuteException e) {
    logger.warn("String_Node_Str" + proc.getNodeName());
    jobService.unreserveTask(task);
    dispatchService.cleanupFailedDispatch(proc);
  }
catch (  Exception e) {
    logger.warn("String_Node_Str" + e);
    jobService.unreserveTask(task);
    dispatchService.cleanupFailedDispatch(proc);
  }
  return false;
}

Fixed version (ground truth):
public boolean dispatch(DispatchProc proc,DispatchTask task){
  if (!dispatchService.reserveTask(task)) {
    logger.warn("String_Node_Str",task.getName());
    return false;
  }
  try {
    dispatchService.assignProc(proc,task);
    if (jobService.startTask(task,proc)) {
      dispatchSupport.runRndTask(task,proc);
      return true;
    }
  }
 catch (  RndClientExecuteException e) {
    logger.warn("String_Node_Str" + proc.getNodeName());
    jobService.unreserveTask(task);
    dispatchService.unbookProc(proc);
  }
catch (  Exception e) {
    logger.warn("String_Node_Str" + e);
    jobService.unreserveTask(task);
    dispatchService.unbookProc(proc);
  }
  return false;
}
Program: 87248
Project: 87248
Buggy source:
@Override public JobT mapRow(ResultSet rs,int rowNum) throws SQLException {
  JobT job=new JobT();
  job.id=rs.getString("String_Node_Str");
  job.name=rs.getString("String_Node_Str");
  job.paused=rs.getBoolean("String_Node_Str");
  job.maxCores=rs.getInt("String_Node_Str");
  job.maxCores=rs.getInt("String_Node_Str");
  job.startTime=rs.getLong("String_Node_Str");
  job.stopTime=rs.getLong("String_Node_Str");
  job.state=JobState.findByValue(rs.getInt("String_Node_Str"));
  job.totalTaskCount=rs.getInt("String_Node_Str");
  job.succeededTaskCount=rs.getInt("String_Node_Str");
  job.runningTaskCount=rs.getInt("String_Node_Str");
  job.deadTaskCount=rs.getInt("String_Node_Str");
  job.eatenTaskCount=rs.getInt("String_Node_Str");
  job.waitingTaskCount=rs.getInt("String_Node_Str");
  job.dependTaskCount=rs.getInt("String_Node_Str");
  return job;
}

Fixed version (ground truth):
@Override public JobT mapRow(ResultSet rs,int rowNum) throws SQLException {
  JobT job=new JobT();
  job.id=rs.getString("String_Node_Str");
  job.name=rs.getString("String_Node_Str");
  job.paused=rs.getBoolean("String_Node_Str");
  job.maxCores=rs.getInt("String_Node_Str");
  job.minCores=rs.getInt("String_Node_Str");
  job.startTime=rs.getLong("String_Node_Str");
  job.stopTime=rs.getLong("String_Node_Str");
  job.state=JobState.findByValue(rs.getInt("String_Node_Str"));
  job.totalTaskCount=rs.getInt("String_Node_Str");
  job.succeededTaskCount=rs.getInt("String_Node_Str");
  job.runningTaskCount=rs.getInt("String_Node_Str");
  job.deadTaskCount=rs.getInt("String_Node_Str");
  job.eatenTaskCount=rs.getInt("String_Node_Str");
  job.waitingTaskCount=rs.getInt("String_Node_Str");
  job.dependTaskCount=rs.getInt("String_Node_Str");
  return job;
}
Program: 87249
Project: 87249
Buggy source:
@Override public Task mapRow(ResultSet rs,int rowNum) throws SQLException {
  TaskE frame=new TaskE();
  frame.setTaskId(UUID.fromString(rs.getString(1)));
  frame.setLayerId(UUID.fromString(rs.getString(2)));
  return frame;
}

Fixed version (ground truth):
@Override public Task mapRow(ResultSet rs,int rowNum) throws SQLException {
  TaskE frame=new TaskE();
  frame.setTaskId(UUID.fromString(rs.getString(1)));
  frame.setLayerId(UUID.fromString(rs.getString(2)));
  frame.setJobId((UUID)rs.getObject(3));
  return frame;
}
Program: 87250
Project: 87250
Buggy source:
@Override public Task create(Layer layer,int number,int taskOrder,int layerOrder){
  final UUID id=UUID.randomUUID();
  jdbc.update(INSERT,id,layer.getLayerId(),null,number,taskOrder,TaskState.INITIALIZE.ordinal());
  TaskE task=new TaskE();
  task.setTaskId(id);
  task.setLayerId(layer.getLayerId());
  return task;
}

Fixed version (ground truth):
@Override public Task create(Layer layer,int number,int taskOrder,int layerOrder){
  final UUID id=UUID.randomUUID();
  jdbc.update(INSERT,id,layer.getLayerId(),null,number,taskOrder,TaskState.INITIALIZE.ordinal());
  TaskE task=new TaskE();
  task.setTaskId(id);
  task.setLayerId(layer.getLayerId());
  task.setJobId(layer.getJobId());
  return task;
}
Program: 87251
Project: 87251
Buggy source:
@Override public Node createNode(Ping ping){
  Cluster cluster=clusterDao.getCluster("String_Node_Str");
  return nodeDao.create(cluster,ping);
}

Fixed version (ground truth):
@Override public Node createNode(Ping ping){
  Cluster cluster=clusterDao.getCluster(UUID.fromString("String_Node_Str"));
  return nodeDao.create(cluster,ping);
}
Program: 87252
Project: 87252
Buggy source:
public List<DispatchProject> getSortedProjectList(final DispatchNode node){
  List<DispatchProject> result=jdbc.query(GET_SORTED_PROJECTS,DPROJECT_MAPPER,node.getClusterId());
  Collections.sort(result,new Comparator<DispatchProject>(){
    @Override public int compare(    DispatchProject o1,    DispatchProject o2){
      return Floats.compare(o1.getTier(),o2.getTier());
    }
  }
);
  return result;
}

Fixed version (ground truth):
@Override public List<DispatchProject> getSortedProjectList(final Node node){
  List<DispatchProject> result=jdbc.query(GET_SORTED_PROJECTS,DPROJECT_MAPPER,node.getClusterId());
  Collections.sort(result,new Comparator<DispatchProject>(){
    @Override public int compare(    DispatchProject o1,    DispatchProject o2){
      return Floats.compare(o1.getTier(),o2.getTier());
    }
  }
);
  return result;
}
Program: 87253
Project: 87253
Buggy source:
@Override public boolean OnInflateProperty(String nameSpace,String attrName,String attrValue){
  String value=null;
  if (NAMESPACE_ANDROID.equals(nameSpace)) {
    if (ATTRIBUTE_SRC.equals(attrName)) {
      src=IFlaterTools.getDrawableLocal(attrValue,getContext());
    }
  }
 else {
    if ((NAMESPACE_ANDROID + "String_Node_Str" + ATTRIBUTE_SRC).equals(attrName)) {
      src=IFlaterTools.getDrawableLocal(attrValue,getContext());
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean OnInflateProperty(String nameSpace,String attrName,String attrValue){
  String value=null;
  if (NAMESPACE_ANDROID.equals(nameSpace)) {
    if (ATTRIBUTE_SRC.equals(attrName)) {
      if (attrValue.startsWith("String_Node_Str")) {
        src=IFlaterTools.getBackgroundColor(attrValue,getContext());
      }
 else       if (attrValue.startsWith("String_Node_Str")) {
        imageSrcuri=IFlaterTools.getDrawableInternet(attrValue);
      }
 else {
        src=IFlaterTools.getDrawableLocal(attrValue,getContext());
      }
    }
  }
 else {
    if ((NAMESPACE_ANDROID + "String_Node_Str" + ATTRIBUTE_SRC).equals(attrName)) {
      if (attrValue.startsWith("String_Node_Str")) {
        src=IFlaterTools.getBackgroundColor(attrValue,getContext());
      }
 else       if (attrValue.startsWith("String_Node_Str")) {
        imageSrcuri=IFlaterTools.getDrawableInternet(attrValue);
      }
 else {
        src=IFlaterTools.getDrawableLocal(attrValue,getContext());
      }
    }
  }
  return false;
}
Program: 87254
Project: 87254
Buggy source:
@Override public void onFinishLayout(View lay){
  ImageView layout=(ImageView)lay;
  if (null != imageuri) {
    imageLoader.displayImage(imageuri,layout,options,animateFirstListener);
  }
}

Fixed version (ground truth):
@Override public void onFinishLayout(View lay){
  ImageView layout=(ImageView)lay;
  if (null != imageSrcuri) {
    imageLoader.displayImage(imageSrcuri,layout,options,animateFirstListener);
  }
}
Program: 87255
Project: 87255
Buggy source:
public static int px2dip(Context context,float pxValue){
  int px=(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,pxValue,context.getResources().getDisplayMetrics());
  return px;
}

Fixed version (ground truth):
public static int px2dip(Context context,float pxValue){
  if (NONE_FLOAT == scale) {
    scale=context.getResources().getDisplayMetrics().density;
  }
  return (int)(pxValue / scale + 0.5f);
}
Program: 87256
Project: 87256
Buggy source:
public void finishIFlate(final View layout){
  layout.setPadding(paddingLeft == NONE_INT ? 0 : paddingLeft,paddingTop == NONE_INT ? 0 : paddingTop,paddingRight == NONE_INT ? 0 : paddingRight,paddingBottom == NONE_INT ? 0 : paddingBottom);
  if (NONE_INT != backgroundColor)   layout.setBackgroundColor(backgroundColor);
  if (NONE_INT != background)   layout.setBackgroundResource(background);
  if (NONE_INT != id)   layout.setId(id);
  if (null != imageuri) {
    imageLoader.loadImage(imageuri,options,new SimpleImageLoadingListener(){
      @Override public void onLoadingComplete(      String imageUri,      View view,      Bitmap loadedImage,      String filePath){
        try {
          Debug.dLog("String_Node_Str" + filePath);
          layout.setBackground(new BitmapDrawable(loadedImage));
          layout.postInvalidate();
        }
 catch (        Exception e) {
          Debug.dLog(e);
        }
        super.onLoadingComplete(imageUri,view,loadedImage,filePath);
      }
    }
);
  }
  onFinishIFlate(layout);
}

Fixed version (ground truth):
public void finishIFlate(final View layout){
  layout.setPadding(paddingLeft == NONE_INT ? 0 : paddingLeft,paddingTop == NONE_INT ? 0 : paddingTop,paddingRight == NONE_INT ? 0 : paddingRight,paddingBottom == NONE_INT ? 0 : paddingBottom);
  if (NONE_INT != backgroundColor)   layout.setBackgroundColor(backgroundColor);
  if (NONE_INT != background)   layout.setBackgroundResource(background);
  if (NONE_INT != id)   layout.setId(id);
  if (null != imageuri) {
    imageLoader.loadImage(imageuri,options,new SimpleImageLoadingListener(){
      @Override public void onLoadingComplete(      String imageUri,      View view,      Bitmap loadedImage,      String filePath){
        try {
          Debug.dLog("String_Node_Str" + filePath);
          layout.setBackgroundDrawable(new BitmapDrawable(loadedImage));
          layout.postInvalidate();
        }
 catch (        Exception e) {
          Debug.dLog(e);
        }
        super.onLoadingComplete(imageUri,view,loadedImage,filePath);
      }
    }
);
  }
  onFinishIFlate(layout);
}
Program: 87257
Project: 87257
Buggy source:
@Override public void onLoadingComplete(String imageUri,View view,Bitmap loadedImage,String filePath){
  try {
    Debug.dLog("String_Node_Str" + filePath);
    layout.setBackground(new BitmapDrawable(loadedImage));
    layout.postInvalidate();
  }
 catch (  Exception e) {
    Debug.dLog(e);
  }
  super.onLoadingComplete(imageUri,view,loadedImage,filePath);
}

Fixed version (ground truth):
@Override public void onLoadingComplete(String imageUri,View view,Bitmap loadedImage,String filePath){
  try {
    Debug.dLog("String_Node_Str" + filePath);
    layout.setBackgroundDrawable(new BitmapDrawable(loadedImage));
    layout.postInvalidate();
  }
 catch (  Exception e) {
    Debug.dLog(e);
  }
  super.onLoadingComplete(imageUri,view,loadedImage,filePath);
}
Program: 87258
Project: 87258
Buggy source:
protected DistributedLockService(DistributedDataStructureFactory distributedDataStructureFactory){
  if (distributedDataStructureFactory == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.distributedDataStructureFactory=distributedDataStructureFactory;
  this.nodeId=distributedDataStructureFactory.getNodeId();
  this.nodesToExclusiveLocks=distributedDataStructureFactory.getMultiMap(getLockMapName());
  this.lockServiceLock=distributedDataStructureFactory.getLock(getServiceLockName());
  this.iAmCleanUpNode=lockServiceLock.tryLock();
}

Fixed version (ground truth):
protected DistributedLockService(DistributedDataStructureFactory distributedDataStructureFactory){
  if (distributedDataStructureFactory == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.distributedDataStructureFactory=distributedDataStructureFactory;
  this.nodeId=distributedDataStructureFactory.getNodeId();
  this.nodesToExclusiveLocks=distributedDataStructureFactory.getMultiMap(getLockMapName());
  this.lockServiceLock=distributedDataStructureFactory.getLock(getServiceLockName());
}
Program: 87259
Project: 87259
Buggy source:
@Override public void memberRemoved(final String uuid){
  iAmCleanUpNode=lockServiceLock.tryLock();
  if (iAmCleanUpNode) {
    executorService.submit(new Runnable(){
      @Override public void run(){
        releaseLocks(uuid);
      }
    }
);
  }
}

Fixed version (ground truth):
@Override public void memberRemoved(final String uuid){
  if (lockServiceLock.tryLock()) {
    try {
      executorService.submit(new Runnable(){
        @Override public void run(){
          releaseLocks(uuid);
        }
      }
);
    }
  finally {
      lockServiceLock.unlock();
    }
  }
}
Program: 87260
Project: 87260
Buggy source:
public void test(){
  Config standardConfig;
  if (crashProcess) {
    standardConfig=new ClasspathXmlConfig("String_Node_Str");
  }
 else {
    standardConfig=new ClasspathXmlConfig("String_Node_Str");
  }
  grid=Hazelcast.newHazelcastInstance(standardConfig);
  latch=grid.getCountDownLatch("String_Node_Str");
  latch.trySetCount(2);
  Locker locker=new Locker();
  new Thread(locker).run();
}

Fixed version (ground truth):
public void test(){
  Config standardConfig;
  if (crashProcess) {
    standardConfig=new ClasspathXmlConfig("String_Node_Str");
  }
 else {
    standardConfig=new ClasspathXmlConfig("String_Node_Str");
  }
  standardConfig.setProperty("String_Node_Str","String_Node_Str");
  grid=Hazelcast.newHazelcastInstance(standardConfig);
  latch=grid.getCountDownLatch("String_Node_Str");
  latch.trySetCount(2);
  Locker locker=new Locker();
  new Thread(locker).run();
}
Program: 87262
Project: 87262
Buggy source:
/** 
 * Release a read or write lock.
 * @throws IllegalMonitorStateException if the current thread holds no locks
 */
void release(){
  monitor.lock();
  try {
    if (holds.get().tryDecrement() == 0) {
      numberOfThreads--;
      writeLockedBy.set(NONE);
      lockAvailable.signalAll();
    }
  }
  finally {
    monitor.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Release a read or write lock.
 * @throws IllegalMonitorStateException if the current thread holds no locks
 */
void release(){
  monitor.lock();
  try {
    if (holds.get().tryDecrement() == 0) {
      numberOfThreads--;
      writeLockedBy=NONE;
      isWriteLocked.set(FALSE);
      holds.remove();
      lockAvailable.signalAll();
    }
  }
  finally {
    monitor.unlock();
  }
}
Program: 87263
Project: 87263
Buggy source:
/** 
 * Acquire a read lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireShared() throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  monitor.lockInterruptibly();
  try {
    if (holds.get().count > 0) {
      holds.get().count++;
    }
 else {
      while (!(writeCount.get() == 0 && writeLockedBy.get() == NONE)) {
        lockAvailable.await();
      }
      holds.get().count=1;
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Acquire a read lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireShared() throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  monitor.lockInterruptibly();
  try {
    if (holds.get().count > 0) {
      holds.get().count++;
    }
 else {
      while (!(writersWaiting.get() == 0 && isWriteLocked.get() == FALSE)) {
        lockAvailable.await();
      }
      holds.get().count=1;
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}
Program: 87264
Project: 87264
Buggy source:
/** 
 * Try and acquire an exclusive lock if it can be done in the time allowed.
 * @param l timeout amount
 * @param timeUnit timeout units
 * @return true if lock acquired; false o/w or if timeout is <= 0
 * @throws InterruptedException
 */
boolean tryAcquireExclusive(final long l,final TimeUnit timeUnit) throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  if (l <= 0)   return false;
  final ElapsedTimer timer=new ElapsedTimer(timeUnit.toMillis(l));
  if (!monitor.tryLock(timer.remainingMillis(),TimeUnit.MILLISECONDS))   return false;
  try {
    final long tid=getThread().getId();
    if (writeLockedBy.get() == tid) {
      holds.get().count++;
    }
 else {
      writeCount.incrementAndGet();
      while (numberOfThreads > 0) {
        try {
          if (!lockAvailable.await(timer.remainingMillis(),TimeUnit.MILLISECONDS)) {
            writeCount.decrementAndGet();
            return false;
          }
        }
 catch (        InterruptedException e) {
          writeCount.decrementAndGet();
          throw e;
        }
      }
      writeCount.decrementAndGet();
      holds.get().count=1;
      writeLockedBy.set(tid);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Try and acquire an exclusive lock if it can be done in the time allowed.
 * @param l timeout amount
 * @param timeUnit timeout units
 * @return true if lock acquired; false o/w or if timeout is <= 0
 * @throws InterruptedException
 */
boolean tryAcquireExclusive(final long l,final TimeUnit timeUnit) throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  if (l <= 0)   return false;
  final ElapsedTimer timer=new ElapsedTimer(timeUnit.toMillis(l));
  if (!monitor.tryLock(timer.remainingMillis(),TimeUnit.MILLISECONDS))   return false;
  try {
    final long tid=getThread().getId();
    if (writeLockedBy == tid) {
      holds.get().count++;
    }
 else {
      writersWaiting.incrementAndGet();
      while (numberOfThreads > 0) {
        try {
          if (!lockAvailable.await(timer.remainingMillis(),TimeUnit.MILLISECONDS)) {
            writersWaiting.decrementAndGet();
            return false;
          }
        }
 catch (        InterruptedException e) {
          writersWaiting.decrementAndGet();
          throw e;
        }
      }
      writersWaiting.decrementAndGet();
      holds.get().count=1;
      writeLockedBy=tid;
      isWriteLocked.set(TRUE);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
  return true;
}
Program: 87265
Project: 87265
Buggy source:
/** 
 * @return whether the current thread owns the write lock
 */
public boolean isHeldByCurrentThread(){
  return lockImpl.writeLockedBy.get() == getThread().getId();
}

Fixed version (ground truth):
/** 
 * @return whether the current thread owns the write lock
 */
public boolean isHeldByCurrentThread(){
  return lockImpl.isWriteLocked.get() == getThread().getId();
}
Program: 87266
Project: 87266
Buggy source:
/** 
 * @return true if anyone has the write lock.
 */
public boolean isWriteLocked(){
  return (lockImpl.writeLockedBy.get() != LockImpl.NONE);
}

Fixed version (ground truth):
/** 
 * @return true if anyone has the write lock.
 */
public boolean isWriteLocked(){
  return (lockImpl.isWriteLocked.get() != LockImpl.NONE);
}
Program: 87267
Project: 87267
Buggy source:
/** 
 * Acquire a write lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireExclusive() throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  monitor.lockInterruptibly();
  try {
    final long tid=getThread().getId();
    if (writeLockedBy.get() == tid) {
      holds.get().count++;
    }
 else {
      writeCount.incrementAndGet();
      while (numberOfThreads > 0) {
        try {
          lockAvailable.await();
        }
 catch (        InterruptedException e) {
          writeCount.decrementAndGet();
          throw e;
        }
      }
      writeCount.decrementAndGet();
      holds.get().count=1;
      writeLockedBy.set(tid);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Acquire a write lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireExclusive() throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  monitor.lockInterruptibly();
  try {
    final long tid=getThread().getId();
    if (writeLockedBy == tid) {
      holds.get().count++;
    }
 else {
      writersWaiting.incrementAndGet();
      while (numberOfThreads > 0) {
        try {
          lockAvailable.await();
        }
 catch (        InterruptedException e) {
          writersWaiting.decrementAndGet();
          throw e;
        }
      }
      writersWaiting.decrementAndGet();
      holds.get().count=1;
      writeLockedBy=tid;
      isWriteLocked.set(TRUE);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}
Program: 87268
Project: 87268
Buggy source:
LockImpl(final DistributedDataStructureFactory grid,final String lockName){
  this.monitor=grid.getLock(lockName + "String_Node_Str");
  this.lockAvailable=grid.getCondition(monitor,lockName + "String_Node_Str");
  this.writeCount=grid.getAtomicLong(lockName + "String_Node_Str");
  this.writeLockedBy=grid.getAtomicLong(lockName + "String_Node_Str");
}

Fixed version (ground truth):
LockImpl(final DistributedDataStructureFactory grid,final String lockName){
  this.monitor=grid.getLock(lockName + "String_Node_Str");
  this.lockAvailable=grid.getCondition(monitor,lockName + "String_Node_Str");
  this.writersWaiting=grid.getAtomicLong(lockName + "String_Node_Str");
  this.isWriteLocked=grid.getAtomicLong(lockName + "String_Node_Str");
}
Program: 87269
Project: 87269
Buggy source:
/** 
 * Acquire a shared lock only if it can be done in the given time.
 * @param l timeout amount
 * @param timeUnit timeout units
 * @return true if the exclusive lock was acquired; false o/w or if timeout was <= 0
 * @throws InterruptedException if the thread is interrupted
 */
boolean tryAcquireShared(final long l,final TimeUnit timeUnit) throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  if (l <= 0)   return false;
  final ElapsedTimer timer=new ElapsedTimer(timeUnit.toMillis(l));
  if (!monitor.tryLock(timer.remainingMillis(),TimeUnit.MILLISECONDS))   return false;
  try {
    if (holds.get().count > 0) {
      holds.get().count++;
    }
 else {
      while (!(writeCount.get() == 0 && writeLockedBy.get() == NONE)) {
        if (!lockAvailable.await(timer.remainingMillis(),TimeUnit.MILLISECONDS)) {
          return false;
        }
      }
      holds.get().count=1;
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Acquire a shared lock only if it can be done in the given time.
 * @param l timeout amount
 * @param timeUnit timeout units
 * @return true if the exclusive lock was acquired; false o/w or if timeout was <= 0
 * @throws InterruptedException if the thread is interrupted
 */
boolean tryAcquireShared(final long l,final TimeUnit timeUnit) throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  if (l <= 0)   return false;
  final ElapsedTimer timer=new ElapsedTimer(timeUnit.toMillis(l));
  if (!monitor.tryLock(timer.remainingMillis(),TimeUnit.MILLISECONDS))   return false;
  try {
    if (holds.get().count > 0) {
      holds.get().count++;
    }
 else {
      while (!(writersWaiting.get() == 0 && isWriteLocked.get() == FALSE)) {
        if (!lockAvailable.await(timer.remainingMillis(),TimeUnit.MILLISECONDS)) {
          return false;
        }
      }
      holds.get().count=1;
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
  return true;
}
Program: 87270
Project: 87270
Buggy source:
/** 
 * Acquire a read lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireShared() throws InterruptedException {
  monitor.lockInterruptibly();
  try {
    if (holds.get().count > 0) {
      holds.get().count++;
    }
 else {
      while (!(writeCount.get() == 0 && writeLockedBy.get() == NONE)) {
        lockAvailable.await();
      }
      holds.get().count=1;
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Acquire a read lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireShared() throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  monitor.lockInterruptibly();
  try {
    if (holds.get().count > 0) {
      holds.get().count++;
    }
 else {
      while (!(writeCount.get() == 0 && writeLockedBy.get() == NONE)) {
        lockAvailable.await();
      }
      holds.get().count=1;
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}
Program: 87271
Project: 87271
Buggy source:
/** 
 * Try and acquire an exclusive lock if it can be done in the time allowed.
 * @param l timeout amount
 * @param timeUnit timeout units
 * @return true if lock acquired; false o/w or if timeout is <= 0
 * @throws InterruptedException
 */
boolean tryAcquireExclusive(final long l,final TimeUnit timeUnit) throws InterruptedException {
  if (l <= 0)   return false;
  final ElapsedTimer timer=new ElapsedTimer(timeUnit.toMillis(l));
  if (!monitor.tryLock(timer.remainingMillis(),TimeUnit.MILLISECONDS))   return false;
  try {
    final long tid=getThread().getId();
    if (writeLockedBy.get() == tid) {
      holds.get().count++;
    }
 else {
      writeCount.incrementAndGet();
      while (numberOfThreads > 0) {
        if (!lockAvailable.await(timer.remainingMillis(),TimeUnit.MILLISECONDS)) {
          writeCount.decrementAndGet();
          return false;
        }
      }
      writeCount.decrementAndGet();
      holds.get().count=1;
      writeLockedBy.set(tid);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Try and acquire an exclusive lock if it can be done in the time allowed.
 * @param l timeout amount
 * @param timeUnit timeout units
 * @return true if lock acquired; false o/w or if timeout is <= 0
 * @throws InterruptedException
 */
boolean tryAcquireExclusive(final long l,final TimeUnit timeUnit) throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  if (l <= 0)   return false;
  final ElapsedTimer timer=new ElapsedTimer(timeUnit.toMillis(l));
  if (!monitor.tryLock(timer.remainingMillis(),TimeUnit.MILLISECONDS))   return false;
  try {
    final long tid=getThread().getId();
    if (writeLockedBy.get() == tid) {
      holds.get().count++;
    }
 else {
      writeCount.incrementAndGet();
      while (numberOfThreads > 0) {
        try {
          if (!lockAvailable.await(timer.remainingMillis(),TimeUnit.MILLISECONDS)) {
            writeCount.decrementAndGet();
            return false;
          }
        }
 catch (        InterruptedException e) {
          writeCount.decrementAndGet();
          throw e;
        }
      }
      writeCount.decrementAndGet();
      holds.get().count=1;
      writeLockedBy.set(tid);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
  return true;
}
Program: 87272
Project: 87272
Buggy source:
/** 
 * Acquire a write lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireExclusive() throws InterruptedException {
  monitor.lockInterruptibly();
  try {
    final long tid=getThread().getId();
    if (writeLockedBy.get() == tid) {
      holds.get().count++;
    }
 else {
      writeCount.incrementAndGet();
      while (numberOfThreads > 0) {
        lockAvailable.await();
      }
      writeCount.decrementAndGet();
      holds.get().count=1;
      writeLockedBy.set(tid);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Acquire a write lock.
 * @throws InterruptedException if the current thread is interrupted
 */
void acquireExclusive() throws InterruptedException {
  if (getThread().isInterrupted())   throw new InterruptedException();
  monitor.lockInterruptibly();
  try {
    final long tid=getThread().getId();
    if (writeLockedBy.get() == tid) {
      holds.get().count++;
    }
 else {
      writeCount.incrementAndGet();
      while (numberOfThreads > 0) {
        try {
          lockAvailable.await();
        }
 catch (        InterruptedException e) {
          writeCount.decrementAndGet();
          throw e;
        }
      }
      writeCount.decrementAndGet();
      holds.get().count=1;
      writeLockedBy.set(tid);
      numberOfThreads++;
    }
  }
  finally {
    monitor.unlock();
  }
}