Program: 49175
Project: 49175
Buggy source:
@Override protected final void invoke(){
  Collection<MemberImpl> members=getClientEngine().getClusterService().getMemberList();
  int partitionCount=getClientEngine().getPartitionService().getPartitionCount();
  Set<Integer> plist=new HashSet<Integer>(partitionCount);
  final ClientEndpoint endpoint=getEndpoint();
  QueryDataResultStream result=new QueryDataResultStream(iterationType,true);
  try {
    List<Future> flist=new ArrayList<Future>();
    final Predicate predicate=getPredicate();
    for (    MemberImpl member : members) {
      Invocation invocation=createInvocationBuilder(SERVICE_NAME,new QueryOperation(name,predicate),member.getAddress()).build();
      Future future=invocation.invoke();
      flist.add(future);
    }
    for (    Future future : flist) {
      QueryResult queryResult=(QueryResult)future.get();
      if (queryResult != null) {
        final List<Integer> partitionIds=queryResult.getPartitionIds();
        if (partitionIds != null) {
          plist.addAll(partitionIds);
          result.addAll(queryResult.getResult());
        }
      }
    }
    if (plist.size() != partitionCount) {
      List<Integer> missingList=new ArrayList<Integer>();
      for (int i=0; i < partitionCount; i++) {
        if (!plist.contains(i)) {
          missingList.add(i);
        }
      }
      List<Future> futures=new ArrayList<Future>(missingList.size());
      for (      Integer pid : missingList) {
        QueryPartitionOperation queryPartitionOperation=new QueryPartitionOperation(name,predicate);
        queryPartitionOperation.setPartitionId(pid);
        try {
          Future f=createInvocationBuilder(SERVICE_NAME,queryPartitionOperation,pid).build().invoke();
          futures.add(f);
        }
 catch (        Throwable t) {
          throw ExceptionUtil.rethrow(t);
        }
      }
      for (      Future future : futures) {
        QueryResult queryResult=(QueryResult)future.get();
        result.addAll(queryResult.getResult());
      }
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
    throw ExceptionUtil.rethrow(t);
  }
 finally {
    result.end();
  }
  getClientEngine().sendResponse(endpoint,result);
}

Fixed version (ground truth):
@Override protected final void invoke(){
  Collection<MemberImpl> members=getClientEngine().getClusterService().getMemberList();
  int partitionCount=getClientEngine().getPartitionService().getPartitionCount();
  Set<Integer> plist=new HashSet<Integer>(partitionCount);
  final ClientEndpoint endpoint=getEndpoint();
  QueryResultSet result=new QueryResultSet(null,iterationType,true);
  try {
    List<Future> flist=new ArrayList<Future>();
    final Predicate predicate=getPredicate();
    for (    MemberImpl member : members) {
      Invocation invocation=createInvocationBuilder(SERVICE_NAME,new QueryOperation(name,predicate),member.getAddress()).build();
      Future future=invocation.invoke();
      flist.add(future);
    }
    for (    Future future : flist) {
      QueryResult queryResult=(QueryResult)future.get();
      if (queryResult != null) {
        final List<Integer> partitionIds=queryResult.getPartitionIds();
        if (partitionIds != null) {
          plist.addAll(partitionIds);
          result.addAll(queryResult.getResult());
        }
      }
    }
    if (plist.size() != partitionCount) {
      List<Integer> missingList=new ArrayList<Integer>();
      for (int i=0; i < partitionCount; i++) {
        if (!plist.contains(i)) {
          missingList.add(i);
        }
      }
      List<Future> futures=new ArrayList<Future>(missingList.size());
      for (      Integer pid : missingList) {
        QueryPartitionOperation queryPartitionOperation=new QueryPartitionOperation(name,predicate);
        queryPartitionOperation.setPartitionId(pid);
        try {
          Future f=createInvocationBuilder(SERVICE_NAME,queryPartitionOperation,pid).build().invoke();
          futures.add(f);
        }
 catch (        Throwable t) {
          throw ExceptionUtil.rethrow(t);
        }
      }
      for (      Future future : futures) {
        QueryResult queryResult=(QueryResult)future.get();
        result.addAll(queryResult.getResult());
      }
    }
  }
 catch (  Throwable t) {
    throw ExceptionUtil.rethrow(t);
  }
  getClientEngine().sendResponse(endpoint,result);
}