https://bz.apache.org/bugzilla/show_bug.cgi?id=56777

--- Comment #16 from Huxing Zhang <huxing.zh...@gmail.com> ---
(In reply to Violeta Georgieva from comment #15)
> (In reply to Huxing Zhang from comment #14)
> > Created attachment 33220 [details]
> > patch that also avoid bug 58518
> > 
> > Well, since Mark has already fixed bug 58518, I have also back ported this
> > fix into tomcat 7.0.x.
> 
> Please check the following discussion
> http://marc.info/?t=144578052500001&r=1&w=2

Thanks for your information, How about the following implementation
ConfigFileLoader, which I think it can avoid:
1) twice hard disk access.
2) resolving file paths that contains space.

public static InputStream getInputStream(String location) throws IOException {
        // Absolute URIs will be left alone
        // Relative files will be resolved relative to catalina base
        // Absolute files will be converted to URIs

        // Location was originally always a file before URI support was added
so
        // try file first.

        // First guess, an absolute file path
        File file = new File(location);

        if (!file.isAbsolute()) {
            // Second guess, a file path relative to CATALINA_BASE
            file = new File(CATALINA_BASE_FILE, location);
        }

        if (file.isFile()) {
            return new FileInputStream(file);
        }

        // Third and final guess, a URI
        URI uri = CATALINA_BASE_URI.resolve(location);
        return uri.toURL().openStream();
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to