commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mfncoo...@gmail.com>
Subject Re: Possible bug? [validator]
Date Mon, 20 Jun 2005 17:19:15 GMT
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 <jopaki@gmail.com> 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
> jopaki@yahoo.com
> --
> -jpk-
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message