Program: 101099
Project: 101099
Buggy source:
@Override public void processUpgrade(String oldVersion,String newVersion){
  LOG.info("String_Node_Str",this.getClass().getName());
  if (service instanceof PicketLinkIDMOrganizationServiceImpl) {
    final PicketLinkIDMOrganizationServiceImpl impl=(PicketLinkIDMOrganizationServiceImpl)service;
    if (!impl.getConfiguration().isDisableUserActived()) {
      LOG.info("String_Node_Str");
      return;
    }
    final UserHandler handler=service.getUserHandler();
    ListAccess<User> users=null;
    int size=0;
    try {
      RequestLifeCycle.begin(impl);
      users=handler.findAllUsers(UserStatus.ANY);
      size=users.getSize();
    }
 catch (    Exception ex) {
      LOG.error(ex);
    }
 finally {
      RequestLifeCycle.end();
    }
    batchSize=batchSize > size ? size : batchSize;
    int tSize=size / threadNum;
    tSize=tSize > 0 ? tSize : size;
    final int odd=tSize == size ? 0 : size % threadNum;
    LOG.info("String_Node_Str",size,threadNum,batchSize);
    ExecutorService execService=Executors.newFixedThreadPool(threadNum);
    final AtomicLong count=new AtomicLong();
    List<Future<Boolean>> results=new LinkedList<Future<Boolean>>();
    final ExoContainer container=ExoContainerContext.getCurrentContainer();
    final PicketLinkIDMService idmService=container.getComponentInstanceOfType(PicketLinkIDMService.class);
    final int threadSize=tSize;
    final ListAccess<User> usrs=users;
    final int totalSize=size;
    for (int i=0; i < threadNum; i++) {
      final int idx=i;
      results.add(execService.submit(new Callable<Boolean>(){
        @Override public Boolean call() throws Exception {
          int start=idx * threadSize;
          int end=start + threadSize;
          if (idx == threadNum - 1) {
            end+=odd;
          }
          ExoContainerContext.setCurrentContainer(container);
          int startBatch=start;
          int endBatch=startBatch + batchSize;
          while (endBatch <= totalSize && endBatch <= end && startBatch < endBatch) {
            LOG.info("String_Node_Str",Thread.currentThread(),startBatch,endBatch);
            RequestLifeCycle.begin(impl);
            IdentitySession session=idmService.getIdentitySession();
            User[] tmp=usrs.load(startBatch,endBatch - startBatch);
            try {
              for (              User u : tmp) {
                enableUser(u,session);
              }
              count.addAndGet(endBatch - startBatch);
              startBatch=endBatch;
              endBatch=startBatch + batchSize;
              endBatch=endBatch > end ? end : endBatch;
              LOG.info("String_Node_Str",Thread.currentThread());
            }
 catch (            Exception e) {
              LOG.error("String_Node_Str",e);
              return false;
            }
 finally {
              RequestLifeCycle.end();
            }
          }
          return true;
        }
      }
));
    }
    try {
      for (      Future<Boolean> r : results) {
        if (!r.get()) {
          LOG.error("String_Node_Str");
        }
      }
      LOG.info("String_Node_Str",count.get());
    }
 catch (    Exception ex) {
      LOG.error(ex);
    }
  }
 else {
    LOG.info("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void processUpgrade(String oldVersion,String newVersion){
  LOG.info("String_Node_Str",this.getClass().getName());
  if (service instanceof PicketLinkIDMOrganizationServiceImpl) {
    final PicketLinkIDMOrganizationServiceImpl impl=(PicketLinkIDMOrganizationServiceImpl)service;
    if (!impl.getConfiguration().isDisableUserActived()) {
      LOG.info("String_Node_Str");
      return;
    }
    final UserHandler handler=service.getUserHandler();
    ListAccess<User> users=null;
    int size=0;
    try {
      RequestLifeCycle.begin(impl);
      users=handler.findAllUsers(UserStatus.ANY);
      size=users.getSize();
    }
 catch (    Exception ex) {
      LOG.error(ex);
    }
 finally {
      RequestLifeCycle.end();
    }
    batchSize=batchSize > size ? size : batchSize;
    int tSize=size / threadNum;
    tSize=tSize > 0 ? tSize : size;
    final int odd=tSize == size ? 0 : size % threadNum;
    LOG.info("String_Node_Str",size,threadNum,batchSize);
    ExecutorService execService=Executors.newFixedThreadPool(threadNum);
    final AtomicLong count=new AtomicLong();
    List<Future<Boolean>> results=new LinkedList<Future<Boolean>>();
    final ExoContainer container=ExoContainerContext.getCurrentContainer();
    final PicketLinkIDMService idmService=container.getComponentInstanceOfType(PicketLinkIDMService.class);
    final int threadSize=tSize;
    final ListAccess<User> usrs=users;
    final int totalSize=size;
    for (int i=0; i < threadNum; i++) {
      final int idx=i;
      results.add(execService.submit(new Callable<Boolean>(){
        @Override public Boolean call() throws Exception {
          int start=idx * threadSize;
          int end=start + threadSize;
          if (idx == threadNum - 1) {
            end+=odd;
          }
          ExoContainerContext.setCurrentContainer(container);
          int startBatch=start;
          int endBatch=startBatch + batchSize;
          endBatch=endBatch > end ? end : endBatch;
          while (endBatch <= totalSize && endBatch <= end && startBatch < endBatch) {
            LOG.info("String_Node_Str",Thread.currentThread(),startBatch,endBatch);
            RequestLifeCycle.begin(impl);
            IdentitySession session=idmService.getIdentitySession();
            User[] tmp=usrs.load(startBatch,endBatch - startBatch);
            try {
              for (              User u : tmp) {
                enableUser(u,session);
              }
              count.addAndGet(endBatch - startBatch);
              startBatch=endBatch;
              endBatch=startBatch + batchSize;
              endBatch=endBatch > end ? end : endBatch;
              LOG.info("String_Node_Str",Thread.currentThread());
            }
 catch (            Exception e) {
              LOG.error("String_Node_Str",e);
              return false;
            }
 finally {
              RequestLifeCycle.end();
            }
          }
          return true;
        }
      }
));
    }
    try {
      for (      Future<Boolean> r : results) {
        if (!r.get()) {
          LOG.error("String_Node_Str");
        }
      }
      LOG.info("String_Node_Str",count.get());
    }
 catch (    Exception ex) {
      LOG.error(ex);
    }
  }
 else {
    LOG.info("String_Node_Str");
  }
}