I don't believe this is a bug. The 'results' variable holds the
results for the current field, and a new set of results is created for
each field. The overall results are maintained in the 'allResults'
field, and the contents of 'results' is merged into that near the end
of the loop.

--
Martin Cooper


On 6/20/05, jopaki <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I downloaded commons-validator v1.1.4 and I think I ran into a bug in
> the method:
> 
>     ValidatorResults validate(Map params, Map actions)
>         throws ValidatorException
> 
> specifically the block:
> ********************************
> 
>         for (int fieldNumber = 0; fieldNumber <
> numberOfFieldsToValidate; fieldNumber++) {
> 
>             ValidatorResults results = new ValidatorResults();
>             // this is the "fix the bug" location
> 
>             Iterator dependencies = this.dependencyList.iterator();
>             while (dependencies.hasNext()) {
>                 String depend = (String) dependencies.next();
> 
>                 ValidatorAction action = (ValidatorAction) 
> actions.get(depend);
>                 if (action == null) {
>                     this.handleMissingAction(depend);
>                 }
> 
>                 //ValidatorResults results = new ValidatorResults();
>                 // this is the "original" location that is "buggy"
> 
>                 boolean good =
>                     validateForRule(action, results, actions, params,
> fieldNumber);
> 
>                 allResults.merge(results);
> 
>                 if (!good) {
>                     return allResults;
>                 }
>             }
>         }
> ********************************
> 
> I moved the line that instantiates the local var: 'results'
> (ValidatorResults ) OUTSIDE of the while loop so the validations
> performed based on the dependencies (resolved to actions) are not lost
> between passes of the while loop.
> 
> Please advise.
> 
> Thanks!
> 
> Jon Kirton
> [EMAIL PROTECTED]
> --
> -jpk-
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to