You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Roth, Scott" <sc...@merck.com> on 2004/06/24 01:44:10 UTC

Bug in XMLFileModule

I am pretty sure that I have found a small bug in the XMLFileModule.  I just
wanted to run it by the dev list before I submitted a patch to Bugzilla.

According to the contract exposed in the excalibur SourceValidity interface:

To avoid testing what the actual implementation of the validity object
supports, the invocation order is to first call isValid() and only if this
result is 0 (i.e. "don't know"), then to call isValid(SourceValidity).

The XMLFileModule doesn't first call isValid().
See line 170:
"if (srcVal != null && this.srcVal.isValid(valid) != 1) {"
It goes right to testing isValid(SourceValidity).

Anyway, because the SourceValidity implementations are expecting the 2
methods to both be called, it is possible to get unexpected behavior when
only the second call is made.  In my case (using ExpiresValidity), the file
was being reloaded on every request because this SourceValidity
implementation always returns INVALID for isValid(SourceValidity).  (It
never expects that call to be made because isValid() never returns UNKNOWN.)

Please, let me know if I am missing something or if I have indeed uncovered
a small bug.  I will be happy to submit a patch if it is warranted.
Alternatively, a committer may just want to make the change themselves.  The
code change is very small - replacing line 170 with a few new lines of code
that calls both isValid methods.

Thanks,
Scott Roth


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------

Re: Bug in XMLFileModule

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Roth, Scott wrote:

>The XMLFileModule doesn't first call isValid().
>See line 170:
>"if (srcVal != null && this.srcVal.isValid(valid) != 1) {"
>It goes right to testing isValid(SourceValidity).
>
>Anyway, because the SourceValidity implementations are expecting the 2
>methods to both be called, it is possible to get unexpected behavior when
>only the second call is made.  In my case (using ExpiresValidity), the file
>was being reloaded on every request because this SourceValidity
>implementation always returns INVALID for isValid(SourceValidity).  (It
>never expects that call to be made because isValid() never returns UNKNOWN.)
>  
>

I've committed a fix; please verify that it actually fixes the issue.

Vadim