This is a tiny patch to TurbineTemplateService in fulcrum. Currently in
turbine 3, TurbineTemplateService.templateExists is called (by
DetermineTargetValve via Module.templateExists) to determine if the
target parsed from the request parameters exists within the path of a
configured template engine service. Template engine services are
registered by extension, so templateExists first looks up the template
engine service that is registered for the extension of the target, and
then asks it if the template exists. 

The problem I see is that if no template engine service is registered
for that extension, a null pointer exception is thrown. I believe this
is incorrect behavior, since having no template engine service
registered for the extension implies that the template does not exist,
and the method should return false. 

So before the patch, asking for

        /template/NonExistentTemplate.vm 

returns false, but asking for

        /template/NonExistentTemplate.food

throws an NPE. After the patch, both will return false, causing
DetermineTargetValve to use the configured homepage as the target, which
seems like a more consistent behavior.

Thanks,
James
Index: src/services/java/org/apache/fulcrum/template/TurbineTemplateService.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/template/TurbineTemplateService.java,v
retrieving revision 1.4
diff -r1.4 TurbineTemplateService.java
194c194,202
<         return tes.templateExists(template);
---
> 
>         if (tes != null)
>         {
>             return tes.templateExists(template);
>         }
>         else
>         {
>             return false;
>         }

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

Reply via email to