Program: 35190
Project: 35190
Buggy source:
private <T>SMGetFuture<List<SMGetElement<T>>> smget(final List<BTreeSMGet<T>> smGetList,final int count,final boolean reverse,final Transcoder<T> tc,final SMGetMode smgetMode){
  final String END="String_Node_Str";
  final String TRIMMED="String_Node_Str";
  final String DUPLICATED="String_Node_Str";
  final String DUPLICATED_TRIMMED="String_Node_Str";
  final CountDownLatch blatch=new CountDownLatch(smGetList.size());
  final ConcurrentLinkedQueue<Operation> ops=new ConcurrentLinkedQueue<Operation>();
  final Map<String,CollectionOperationStatus> missedKeys=Collections.synchronizedMap(new HashMap<String,CollectionOperationStatus>());
  final List<String> missedKeyList=Collections.synchronizedList(new ArrayList<String>());
  final int totalResultElementCount=count;
  final List<SMGetElement<T>> mergedResult=Collections.synchronizedList(new ArrayList<SMGetElement<T>>(totalResultElementCount));
  final List<SMGetTrimKey> mergedTrimmedKeys=Collections.synchronizedList(new ArrayList<SMGetTrimKey>());
  final ReentrantLock lock=new ReentrantLock();
  final List<OperationStatus> resultOperationStatus=Collections.synchronizedList(new ArrayList<OperationStatus>(1));
  final List<OperationStatus> failedOperationStatus=Collections.synchronizedList(new ArrayList<OperationStatus>(1));
  final Set<Object> totalBkey=new TreeSet<Object>();
  final AtomicBoolean stopCollect=new AtomicBoolean(false);
  final AtomicInteger processedSMGetCount=new AtomicInteger(smGetList.size());
  for (  BTreeSMGet<T> smGet : smGetList) {
    Operation op=opFact.bopsmget(smGet,new BTreeSortMergeGetOperation.Callback(){
      final List<SMGetElement<T>> eachResult=new ArrayList<SMGetElement<T>>();
      final List<SMGetTrimKey> eachTrimmedResult=new ArrayList<SMGetTrimKey>();
      private void addTotalBkey(      List<SMGetElement<T>> smgetresult){
        for (        SMGetElement<T> each : smgetresult) {
          if (each.getBkeyByObject() instanceof byte[]) {
            totalBkey.add(new ByteArrayBKey((byte[])each.getBkeyByObject()));
          }
 else {
            totalBkey.add(each.getBkeyByObject());
          }
        }
      }
      private boolean addTotalBkey(      Object bkey){
        if (bkey instanceof byte[]) {
          return totalBkey.add(new ByteArrayBKey((byte[])bkey));
        }
 else {
          return totalBkey.add(bkey);
        }
      }
      @Override public void receivedStatus(      OperationStatus status){
        processedSMGetCount.decrementAndGet();
        if (status.isSuccess()) {
          resultOperationStatus.add(status);
        }
 else {
          stopCollect.set(true);
          mergedResult.clear();
          mergedTrimmedKeys.clear();
          failedOperationStatus.add(status);
        }
        if (status.isSuccess()) {
          lock.lock();
          try {
            if (mergedResult.size() == 0) {
              if (smGetList.size() > 1) {
                addTotalBkey(eachResult);
              }
              mergedResult.addAll(eachResult);
            }
 else {
              int idx, pos=0;
              for (              SMGetElement<T> result : eachResult) {
                for (idx=pos; idx < mergedResult.size(); idx++) {
                  if ((reverse) ? (0 < result.compareTo(mergedResult.get(idx))) : (0 > result.compareTo(mergedResult.get(idx))))                   break;
                }
                if (idx < mergedResult.size() || idx < totalResultElementCount) {
                  boolean duplicated=false;
                  if (!addTotalBkey(result.getBkeyByObject())) {
                    resultOperationStatus.add(new OperationStatus(true,"String_Node_Str"));
                    duplicated=true;
                  }
                  if (smgetMode != SMGetMode.UNIQUE || !duplicated) {
                    mergedResult.add(idx,result);
                    if (mergedResult.size() > totalResultElementCount)                     mergedResult.remove(totalResultElementCount);
                  }
                  pos=idx + 1;
                  if (pos >= totalResultElementCount) {
                    break;
                  }
                }
              }
            }
            if (eachTrimmedResult.size() > 0) {
              if (mergedTrimmedKeys.size() == 0) {
                mergedTrimmedKeys.addAll(eachTrimmedResult);
              }
 else {
                int idx, pos=0;
                for (                SMGetTrimKey eTrim : eachTrimmedResult) {
                  for (idx=pos; idx < mergedTrimmedKeys.size(); idx++) {
                    if ((reverse) ? (0 < eTrim.compareTo(mergedTrimmedKeys.get(idx))) : 0 > eTrim.compareTo(mergedTrimmedKeys.get(idx))) {
                      break;
                    }
                  }
                  mergedTrimmedKeys.add(idx,eTrim);
                  pos=idx + 1;
                }
              }
            }
            if (mergedTrimmedKeys.size() > 0 && processedSMGetCount.get() == 0 && count <= mergedResult.size()) {
              SMGetElement<T> lastElement=mergedResult.get(count - 1);
              SMGetTrimKey lastTrimKey=new SMGetTrimKey(lastElement.getKey(),lastElement.getBkeyByObject());
              for (int idx=mergedTrimmedKeys.size() - 1; idx >= 0; idx--) {
                SMGetTrimKey me=mergedTrimmedKeys.get(idx);
                if ((reverse) ? (0 >= me.compareTo(lastTrimKey)) : 0 <= me.compareTo(lastTrimKey)) {
                  mergedTrimmedKeys.remove(idx);
                }
 else {
                  break;
                }
              }
            }
          }
  finally {
            lock.unlock();
          }
        }
 else {
          getLogger().warn("String_Node_Str",status);
        }
      }
      @Override public void complete(){
        blatch.countDown();
      }
      @Override public void gotData(      String key,      Object subkey,      int flags,      byte[] data){
        if (stopCollect.get())         return;
        if (subkey instanceof Long) {
          eachResult.add(new SMGetElement<T>(key,(Long)subkey,tc.decode(new CachedData(flags,data,tc.getMaxSize()))));
        }
 else         if (subkey instanceof byte[]) {
          eachResult.add(new SMGetElement<T>(key,(byte[])subkey,tc.decode(new CachedData(flags,data,tc.getMaxSize()))));
        }
      }
      @Override public void gotMissedKey(      String key,      OperationStatus cause){
        if (cause.getMessage().equals("String_Node_Str"))         missedKeyList.add(key);
 else         missedKeys.put(key,new CollectionOperationStatus(cause));
      }
      @Override public void gotTrimmedKey(      String key,      Object subkey){
        if (stopCollect.get())         return;
        if (subkey instanceof Long) {
          eachTrimmedResult.add(new SMGetTrimKey(key,(Long)subkey));
        }
 else         if (subkey instanceof byte[]) {
          eachTrimmedResult.add(new SMGetTrimKey(key,(byte[])subkey));
        }
      }
    }
);
    ops.add(op);
    addOp(smGet.getRepresentKey(),op);
  }
  return new SMGetFuture<List<SMGetElement<T>>>(ops,operationTimeout){
    @Override public List<SMGetElement<T>> get(    long duration,    TimeUnit units) throws InterruptedException, TimeoutException, ExecutionException {
      if (!blatch.await(duration,units)) {
        for (        Operation op : ops) {
          MemcachedConnection.opTimedOut(op);
        }
        throw new CheckedOperationTimeoutException("String_Node_Str",ops);
      }
 else {
        for (        Operation op : ops) {
          MemcachedConnection.opSucceeded(op);
        }
      }
      for (      Operation op : ops) {
        if (op != null && op.hasErrored()) {
          throw new ExecutionException(op.getException());
        }
      }
      if (isCancelled()) {
        throw new ExecutionException(new RuntimeException("String_Node_Str"));
      }
      if (smGetList.size() == 1)       return mergedResult;
      return getSubList(mergedResult,0,count);
    }
    @Override public Map<String,CollectionOperationStatus> getMissedKeys(){
      return missedKeys;
    }
    @Override public List<String> getMissedKeyList(){
      return missedKeyList;
    }
    @Override public List<SMGetTrimKey> getTrimmedKeys(){
      return mergedTrimmedKeys;
    }
    @Override public CollectionOperationStatus getOperationStatus(){
      if (failedOperationStatus.size() > 0) {
        return new CollectionOperationStatus(failedOperationStatus.get(0));
      }
      OperationStatus end=null;
      OperationStatus duplicated=null;
      OperationStatus trimmed=null;
      OperationStatus duplicatedTrimmed=null;
      for (      OperationStatus status : resultOperationStatus) {
        if (END.equals(status.getMessage()))         end=status;
 else         if (DUPLICATED.equals(status.getMessage()))         duplicated=status;
 else         if (TRIMMED.equals(status.getMessage()))         trimmed=status;
 else         if (DUPLICATED_TRIMMED.equals(status.getMessage()))         duplicatedTrimmed=status;
      }
      if (end == null && duplicated == null && trimmed == null && duplicatedTrimmed == null) {
        getLogger().warn("String_Node_Str");
        return null;
      }
      if (duplicatedTrimmed == null && duplicated != null && trimmed != null)       duplicatedTrimmed=new OperationStatus(true,"String_Node_Str");
      if (duplicatedTrimmed != null)       return new CollectionOperationStatus(duplicatedTrimmed);
 else       if (duplicated != null)       return new CollectionOperationStatus(duplicated);
 else       if (trimmed != null)       return new CollectionOperationStatus(trimmed);
 else       return new CollectionOperationStatus(end);
    }
  }
;
}

Fixed version (ground truth):
private <T>SMGetFuture<List<SMGetElement<T>>> smget(final List<BTreeSMGet<T>> smGetList,final int count,final boolean reverse,final Transcoder<T> tc,final SMGetMode smgetMode){
  final String END="String_Node_Str";
  final String TRIMMED="String_Node_Str";
  final String DUPLICATED="String_Node_Str";
  final String DUPLICATED_TRIMMED="String_Node_Str";
  final CountDownLatch blatch=new CountDownLatch(smGetList.size());
  final ConcurrentLinkedQueue<Operation> ops=new ConcurrentLinkedQueue<Operation>();
  final Map<String,CollectionOperationStatus> missedKeys=Collections.synchronizedMap(new HashMap<String,CollectionOperationStatus>());
  final List<String> missedKeyList=Collections.synchronizedList(new ArrayList<String>());
  final int totalResultElementCount=count;
  final List<SMGetElement<T>> mergedResult=Collections.synchronizedList(new ArrayList<SMGetElement<T>>(totalResultElementCount));
  final List<SMGetTrimKey> mergedTrimmedKeys=Collections.synchronizedList(new ArrayList<SMGetTrimKey>());
  final ReentrantLock lock=new ReentrantLock();
  final List<OperationStatus> resultOperationStatus=Collections.synchronizedList(new ArrayList<OperationStatus>(1));
  final List<OperationStatus> failedOperationStatus=Collections.synchronizedList(new ArrayList<OperationStatus>(1));
  final Set<Object> totalBkey=new TreeSet<Object>();
  final AtomicBoolean stopCollect=new AtomicBoolean(false);
  final AtomicInteger processedSMGetCount=new AtomicInteger(smGetList.size());
  for (  BTreeSMGet<T> smGet : smGetList) {
    Operation op=opFact.bopsmget(smGet,new BTreeSortMergeGetOperation.Callback(){
      final List<SMGetElement<T>> eachResult=new ArrayList<SMGetElement<T>>();
      final List<SMGetTrimKey> eachTrimmedResult=new ArrayList<SMGetTrimKey>();
      private void addTotalBkey(      List<SMGetElement<T>> smgetresult){
        for (        SMGetElement<T> each : smgetresult) {
          if (each.getBkeyByObject() instanceof byte[]) {
            totalBkey.add(new ByteArrayBKey((byte[])each.getBkeyByObject()));
          }
 else {
            totalBkey.add(each.getBkeyByObject());
          }
        }
      }
      private boolean addTotalBkey(      Object bkey){
        if (bkey instanceof byte[]) {
          return totalBkey.add(new ByteArrayBKey((byte[])bkey));
        }
 else {
          return totalBkey.add(bkey);
        }
      }
      @Override public void receivedStatus(      OperationStatus status){
        processedSMGetCount.decrementAndGet();
        if (status.isSuccess()) {
          resultOperationStatus.add(status);
        }
 else {
          stopCollect.set(true);
          mergedResult.clear();
          mergedTrimmedKeys.clear();
          failedOperationStatus.add(status);
        }
        if (status.isSuccess()) {
          lock.lock();
          try {
            if (mergedResult.size() == 0) {
              if (smGetList.size() > 1) {
                addTotalBkey(eachResult);
              }
              mergedResult.addAll(eachResult);
            }
 else {
              boolean duplicated;
              int idx, pos=0;
              for (              SMGetElement<T> result : eachResult) {
                for (idx=pos; idx < mergedResult.size(); idx++) {
                  if ((reverse) ? (0 < result.compareTo(mergedResult.get(idx))) : (0 > result.compareTo(mergedResult.get(idx))))                   break;
                }
                if (idx >= totalResultElementCount) {
                  break;
                }
                if (!addTotalBkey(result.getBkeyByObject())) {
                  resultOperationStatus.add(new OperationStatus(true,"String_Node_Str"));
                  duplicated=true;
                }
 else {
                  duplicated=false;
                }
                if (smgetMode != SMGetMode.UNIQUE || !duplicated) {
                  mergedResult.add(idx,result);
                  if (mergedResult.size() > totalResultElementCount)                   mergedResult.remove(totalResultElementCount);
                  pos=idx + 1;
                }
 else {
                  pos=idx;
                }
              }
            }
            if (eachTrimmedResult.size() > 0) {
              if (mergedTrimmedKeys.size() == 0) {
                mergedTrimmedKeys.addAll(eachTrimmedResult);
              }
 else {
                int idx, pos=0;
                for (                SMGetTrimKey eTrim : eachTrimmedResult) {
                  for (idx=pos; idx < mergedTrimmedKeys.size(); idx++) {
                    if ((reverse) ? (0 < eTrim.compareTo(mergedTrimmedKeys.get(idx))) : 0 > eTrim.compareTo(mergedTrimmedKeys.get(idx))) {
                      break;
                    }
                  }
                  mergedTrimmedKeys.add(idx,eTrim);
                  pos=idx + 1;
                }
              }
            }
            if (mergedTrimmedKeys.size() > 0 && processedSMGetCount.get() == 0 && count <= mergedResult.size()) {
              SMGetElement<T> lastElement=mergedResult.get(count - 1);
              SMGetTrimKey lastTrimKey=new SMGetTrimKey(lastElement.getKey(),lastElement.getBkeyByObject());
              for (int idx=mergedTrimmedKeys.size() - 1; idx >= 0; idx--) {
                SMGetTrimKey me=mergedTrimmedKeys.get(idx);
                if ((reverse) ? (0 >= me.compareTo(lastTrimKey)) : 0 <= me.compareTo(lastTrimKey)) {
                  mergedTrimmedKeys.remove(idx);
                }
 else {
                  break;
                }
              }
            }
          }
  finally {
            lock.unlock();
          }
        }
 else {
          getLogger().warn("String_Node_Str",status);
        }
      }
      @Override public void complete(){
        blatch.countDown();
      }
      @Override public void gotData(      String key,      Object subkey,      int flags,      byte[] data){
        if (stopCollect.get())         return;
        if (subkey instanceof Long) {
          eachResult.add(new SMGetElement<T>(key,(Long)subkey,tc.decode(new CachedData(flags,data,tc.getMaxSize()))));
        }
 else         if (subkey instanceof byte[]) {
          eachResult.add(new SMGetElement<T>(key,(byte[])subkey,tc.decode(new CachedData(flags,data,tc.getMaxSize()))));
        }
      }
      @Override public void gotMissedKey(      String key,      OperationStatus cause){
        if (cause.getMessage().equals("String_Node_Str"))         missedKeyList.add(key);
 else         missedKeys.put(key,new CollectionOperationStatus(cause));
      }
      @Override public void gotTrimmedKey(      String key,      Object subkey){
        if (stopCollect.get())         return;
        if (subkey instanceof Long) {
          eachTrimmedResult.add(new SMGetTrimKey(key,(Long)subkey));
        }
 else         if (subkey instanceof byte[]) {
          eachTrimmedResult.add(new SMGetTrimKey(key,(byte[])subkey));
        }
      }
    }
);
    ops.add(op);
    addOp(smGet.getRepresentKey(),op);
  }
  return new SMGetFuture<List<SMGetElement<T>>>(ops,operationTimeout){
    @Override public List<SMGetElement<T>> get(    long duration,    TimeUnit units) throws InterruptedException, TimeoutException, ExecutionException {
      if (!blatch.await(duration,units)) {
        for (        Operation op : ops) {
          MemcachedConnection.opTimedOut(op);
        }
        throw new CheckedOperationTimeoutException("String_Node_Str",ops);
      }
 else {
        for (        Operation op : ops) {
          MemcachedConnection.opSucceeded(op);
        }
      }
      for (      Operation op : ops) {
        if (op != null && op.hasErrored()) {
          throw new ExecutionException(op.getException());
        }
      }
      if (isCancelled()) {
        throw new ExecutionException(new RuntimeException("String_Node_Str"));
      }
      if (smGetList.size() == 1)       return mergedResult;
      return getSubList(mergedResult,0,count);
    }
    @Override public Map<String,CollectionOperationStatus> getMissedKeys(){
      return missedKeys;
    }
    @Override public List<String> getMissedKeyList(){
      return missedKeyList;
    }
    @Override public List<SMGetTrimKey> getTrimmedKeys(){
      return mergedTrimmedKeys;
    }
    @Override public CollectionOperationStatus getOperationStatus(){
      if (failedOperationStatus.size() > 0) {
        return new CollectionOperationStatus(failedOperationStatus.get(0));
      }
      OperationStatus end=null;
      OperationStatus duplicated=null;
      OperationStatus trimmed=null;
      OperationStatus duplicatedTrimmed=null;
      for (      OperationStatus status : resultOperationStatus) {
        if (END.equals(status.getMessage()))         end=status;
 else         if (DUPLICATED.equals(status.getMessage()))         duplicated=status;
 else         if (TRIMMED.equals(status.getMessage()))         trimmed=status;
 else         if (DUPLICATED_TRIMMED.equals(status.getMessage()))         duplicatedTrimmed=status;
      }
      if (end == null && duplicated == null && trimmed == null && duplicatedTrimmed == null) {
        getLogger().warn("String_Node_Str");
        return null;
      }
      if (duplicatedTrimmed == null && duplicated != null && trimmed != null)       duplicatedTrimmed=new OperationStatus(true,"String_Node_Str");
      if (duplicatedTrimmed != null)       return new CollectionOperationStatus(duplicatedTrimmed);
 else       if (duplicated != null)       return new CollectionOperationStatus(duplicated);
 else       if (trimmed != null)       return new CollectionOperationStatus(trimmed);
 else       return new CollectionOperationStatus(end);
    }
  }
;
}