An IllegalArgumentException is usually thrown to indicate that a method is being invoked with a parameter value that is not useable. In your case,
you should ensure that your candidates variable, which is probably a List, contains at least one element. If candidates is not a List, then you need to figure out what constitutes an "empty" value and do something to correct it before passing it to the method that is throwing the exception.