Program: 90012
Project: 90012
Buggy source:
/** 
 * Generate a criteria query predicate for a where clause based on the given parameters.
 * @param root        The root to use
 * @param cb          The criteria builder to use
 * @param id          The job id
 * @param name        The job name
 * @param user        The user who created the job
 * @param statuses    The job statuses
 * @param tags        The tags for the jobs to find
 * @param clusterName The cluster name
 * @param clusterId   The cluster id
 * @param commandName The command name
 * @param commandId   The command id
 * @param minStarted  The time which the job had to start after in order to be return (inclusive)
 * @param maxStarted  The time which the job had to start before in order to be returned (exclusive)
 * @param minFinished The time which the job had to finish after in order to be return (inclusive)
 * @param maxFinished The time which the job had to finish before in order to be returned (exclusive)
 * @return The specification
 */
public static Predicate getFindPredicate(final Root<JobEntity> root,final CriteriaBuilder cb,final String id,final String name,final String user,final Set<JobStatus> statuses,final Set<String> tags,final String clusterName,final String clusterId,final String commandName,final String commandId,final Date minStarted,final Date maxStarted,final Date minFinished,final Date maxFinished){
  final List<Predicate> predicates=new ArrayList<>();
  if (StringUtils.isNotBlank(id)) {
    predicates.add(cb.like(root.get(JobEntity_.id),id));
  }
  if (StringUtils.isNotBlank(name)) {
    predicates.add(cb.like(root.get(JobEntity_.name),name));
  }
  if (StringUtils.isNotBlank(user)) {
    predicates.add(cb.equal(root.get(JobEntity_.user),user));
  }
  if (statuses != null && !statuses.isEmpty()) {
    final List<Predicate> orPredicates=statuses.stream().map(status -> cb.equal(root.get(JobEntity_.status),status)).collect(Collectors.toList());
    predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()])));
  }
  if (tags != null && !tags.isEmpty()) {
    predicates.add(cb.like(root.get(JobEntity_.tags),JpaSpecificationUtils.getTagLikeString(tags)));
  }
  if (StringUtils.isNotBlank(clusterId)) {
    predicates.add(cb.equal(root.get(JobEntity_.cluster),clusterId));
  }
  if (StringUtils.isNotBlank(clusterName)) {
    predicates.add(cb.equal(root.get(JobEntity_.clusterName),clusterName));
  }
  if (StringUtils.isNotBlank(commandId)) {
    predicates.add(cb.equal(root.get(JobEntity_.command),commandId));
  }
  if (StringUtils.isNotBlank(commandName)) {
    predicates.add(cb.equal(root.get(JobEntity_.commandName),commandName));
  }
  if (minStarted != null) {
    predicates.add(cb.greaterThanOrEqualTo(root.get(JobEntity_.started),minStarted));
  }
  if (maxStarted != null) {
    predicates.add(cb.lessThan(root.get(JobEntity_.started),maxStarted));
  }
  if (minFinished != null) {
    predicates.add(cb.greaterThanOrEqualTo(root.get(JobEntity_.finished),minFinished));
  }
  if (maxFinished != null) {
    predicates.add(cb.lessThan(root.get(JobEntity_.finished),maxFinished));
  }
  return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}

Fixed version (ground truth):
/** 
 * Generate a criteria query predicate for a where clause based on the given parameters.
 * @param root        The root to use
 * @param cb          The criteria builder to use
 * @param id          The job id
 * @param name        The job name
 * @param user        The user who created the job
 * @param statuses    The job statuses
 * @param tags        The tags for the jobs to find
 * @param clusterName The cluster name
 * @param cluster     The cluster the job should have been run on
 * @param commandName The command name
 * @param command     The command the job should have been run with
 * @param minStarted  The time which the job had to start after in order to be return (inclusive)
 * @param maxStarted  The time which the job had to start before in order to be returned (exclusive)
 * @param minFinished The time which the job had to finish after in order to be return (inclusive)
 * @param maxFinished The time which the job had to finish before in order to be returned (exclusive)
 * @return The specification
 */
public static Predicate getFindPredicate(final Root<JobEntity> root,final CriteriaBuilder cb,final String id,final String name,final String user,final Set<JobStatus> statuses,final Set<String> tags,final String clusterName,final ClusterEntity cluster,final String commandName,final CommandEntity command,final Date minStarted,final Date maxStarted,final Date minFinished,final Date maxFinished){
  final List<Predicate> predicates=new ArrayList<>();
  if (StringUtils.isNotBlank(id)) {
    predicates.add(cb.like(root.get(JobEntity_.id),id));
  }
  if (StringUtils.isNotBlank(name)) {
    predicates.add(cb.like(root.get(JobEntity_.name),name));
  }
  if (StringUtils.isNotBlank(user)) {
    predicates.add(cb.equal(root.get(JobEntity_.user),user));
  }
  if (statuses != null && !statuses.isEmpty()) {
    final List<Predicate> orPredicates=statuses.stream().map(status -> cb.equal(root.get(JobEntity_.status),status)).collect(Collectors.toList());
    predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()])));
  }
  if (tags != null && !tags.isEmpty()) {
    predicates.add(cb.like(root.get(JobEntity_.tags),JpaSpecificationUtils.getTagLikeString(tags)));
  }
  if (cluster != null) {
    predicates.add(cb.equal(root.get(JobEntity_.cluster),cluster));
  }
  if (StringUtils.isNotBlank(clusterName)) {
    predicates.add(cb.equal(root.get(JobEntity_.clusterName),clusterName));
  }
  if (command != null) {
    predicates.add(cb.equal(root.get(JobEntity_.command),command));
  }
  if (StringUtils.isNotBlank(commandName)) {
    predicates.add(cb.equal(root.get(JobEntity_.commandName),commandName));
  }
  if (minStarted != null) {
    predicates.add(cb.greaterThanOrEqualTo(root.get(JobEntity_.started),minStarted));
  }
  if (maxStarted != null) {
    predicates.add(cb.lessThan(root.get(JobEntity_.started),maxStarted));
  }
  if (minFinished != null) {
    predicates.add(cb.greaterThanOrEqualTo(root.get(JobEntity_.finished),minFinished));
  }
  if (maxFinished != null) {
    predicates.add(cb.lessThan(root.get(JobEntity_.finished),maxFinished));
  }
  return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}