Bug 52772 - JspC : checking uriRoot option validness
Summary: JspC : checking uriRoot option validness
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: trunk
Hardware: PC Linux
: P2 trivial (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-26 07:41 UTC by Eugene Chung (TmaxSoft)
Modified: 2012-03-07 15:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Chung (TmaxSoft) 2012-02-26 07:41:43 UTC
In org.apache.jasper.JspC#execute() method,
if uriRoot is not null,
it scans all jsp files under uriRoot,
and then checks if uriRoot is a directory.

It should be more desirable to check if uriRoot is a directory or not first and then scanning it.


Here are my suggestion.

            if (uriRoot == null) {
                throw new JasperException(
                    Localizer.getMessage("jsp.error.jspc.no_uriroot"));
            }

            File uriRootF = new File(uriRoot);
            if (!uriRootF.exists() || !uriRootF.isDirectory()) {
                throw new JasperException(
                    Localizer.getMessage("jsp.error.jspc.uriroot_not_dir"));
            }

            if( context==null ) {
                initServletContext();
            }

            // No explicit pages, we'll process all .jsp in the webapp
            if (pages.size() == 0) {
                scanFiles(uriRootF);
            }
Comment 1 Eugene Chung (TmaxSoft) 2012-02-26 07:44:35 UTC
And !uriRootF.exists() || !uriRootF.isDirectory() is redundant. isDirectory() checks existence, too.
Comment 2 Mark Thomas 2012-03-07 15:11:45 UTC
Thanks for the report and the suggested fix.

This issue has been fixed in trunk and 7.0.x and will be included in 7.0.27 onwards.