Program: 37477
Project: 37477
Buggy source:
@Override public void onCollect(String password,String cmd,String key,int requestSize,int responseSize,int procTimeMills,int waitTimeMills,boolean isCommandOnly,boolean isBypass){
  if (isCommandOnly)   return;
  if (requestSize < REQUIRED_SIZE && responseSize < REQUIRED_SIZE) {
    return;
  }
  totalCount.incrementAndGet();
  if (isBypass) {
    bypassCount.incrementAndGet();
  }
  if (!locking.compareAndSet(false,true)) {
    return;
  }
  try {
    if (bkList.size() >= LENGTH) {
      while (bkList.size() >= (LENGTH * 0.5)) {
        int index=bkList.size() - 1;
        BigKey bk=bkList.remove(index);
        if (bk != null) {
          bkHashMap.remove(bk.key);
        }
      }
    }
    BigKey newBK=new BigKey();
    newBK.key=key;
    int index=bkList.indexOf(newBK);
    if (index >= 0) {
      BigKey oldBK=bkHashMap.get(key);
      if (oldBK == null) {
        oldBK=newBK;
        bkHashMap.put(key,oldBK);
      }
      oldBK.lastCmd=cmd;
      oldBK.size=requestSize > responseSize ? requestSize : responseSize;
      oldBK.lastUseTime=TimeUtil.currentTimeMillis();
      oldBK.count.incrementAndGet();
      oldBK.fromReq=requestSize >= REQUIRED_SIZE;
      oldBK.fromResp=responseSize >= REQUIRED_SIZE;
    }
 else {
      newBK.lastCmd=cmd;
      newBK.size=requestSize > responseSize ? requestSize : responseSize;
      newBK.lastUseTime=TimeUtil.currentTimeMillis();
      newBK.fromReq=requestSize >= REQUIRED_SIZE;
      newBK.fromResp=responseSize >= REQUIRED_SIZE;
      bkList.add(newBK);
      bkHashMap.put(key,newBK);
    }
  }
  finally {
    locking.set(false);
  }
}

Fixed version (ground truth):
@Override public void onCollect(String password,String cmd,String key,int requestSize,int responseSize,int procTimeMills,int waitTimeMills,boolean isCommandOnly,boolean isBypass){
  if (isCommandOnly)   return;
  if (requestSize < REQUIRED_SIZE && responseSize < REQUIRED_SIZE) {
    return;
  }
  totalCount.incrementAndGet();
  if (isBypass) {
    bypassCount.incrementAndGet();
  }
  if (!locking.compareAndSet(false,true)) {
    return;
  }
  try {
    if (bkList.size() >= LENGTH) {
      Collections.sort(bkList,new BigKey());
      while (bkList.size() >= (LENGTH * 0.5)) {
        int index=bkList.size() - 1;
        BigKey bk=bkList.remove(index);
        if (bk != null) {
          bkHashMap.remove(bk.key);
        }
      }
    }
    BigKey newBK=new BigKey();
    newBK.key=key;
    int index=bkList.indexOf(newBK);
    if (index >= 0) {
      BigKey oldBK=bkHashMap.get(key);
      if (oldBK == null) {
        oldBK=bkList.get(index);
        if (!key.equals(oldBK.key)) {
          return;
        }
        bkHashMap.put(key,oldBK);
      }
      oldBK.lastCmd=cmd;
      oldBK.size=requestSize > responseSize ? requestSize : responseSize;
      oldBK.lastUseTime=TimeUtil.currentTimeMillis();
      oldBK.count.incrementAndGet();
      oldBK.fromReq=requestSize >= REQUIRED_SIZE;
      oldBK.fromResp=responseSize >= REQUIRED_SIZE;
    }
 else {
      newBK.lastCmd=cmd;
      newBK.size=requestSize > responseSize ? requestSize : responseSize;
      newBK.lastUseTime=TimeUtil.currentTimeMillis();
      newBK.fromReq=requestSize >= REQUIRED_SIZE;
      newBK.fromResp=responseSize >= REQUIRED_SIZE;
      bkList.add(newBK);
      bkHashMap.put(key,newBK);
    }
  }
  finally {
    locking.set(false);
  }
}