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

--- Comment #9 from Konstantin Kolinko <knst.koli...@gmail.com> ---
(In reply to Mark Thomas from comment #8)
> Thanks for the patch. It has been applied (with a few minor tweaks to
> silence some Eclipse warnings) to 7.0.x and will be included in 7.0.63
> onwards.

For a reference, implementation of this feature in Tomcat 7 is
r1681953 + r1724913

Comments working on backport to Tomcat 6
==========================

1). Currently null is an unsupported value for StandardContext.docBase.

Using the null value is going to fail with a NullPointerException thrown
from a "new File(null)" call.

So implementing support for a null docBase is a new feature
and does not break any existing one.


2). There is a slight difference with Tomcat 7 that ApplicationContext and
ReplicatedContext$ReplApplContext constructors accept additional argument
basePath.

    public ServletContext getServletContext() {
        if (context == null) {
            context = new ApplicationContext(getBasePath(), this);

This resulted in a stacktrace like this:

  java.lang.NullPointerException
     at java.io.File.<init>(File.java:194)
     at
org.apache.catalina.core.StandardContext.getBasePath(StandardContext.java:5179)
     at
org.apache.catalina.core.StandardContext.getServletContext(StandardContext.java:1932)
     at
org.apache.catalina.core.StandardContext.postWorkDirectory(StandardContext.java:5448)
     at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4563)

The basePath value is used to implement methods
ApplicationContext.getRealPath(String)
and getResource(String).

(For historic reference: commits that removed basePath field from
ApplicationContext
in Tomcat 7 are r784083 + r834220)

In both methods the use of basePath is conditioned on "if
(context.isFilesystemBased())"
condition. So if StandardContext is not based on a filesystem, the value of
basePath in ApplicationContext does not matter.

Thus I am going to change StandardContext.getBasePath() to return null for a
null docBase,
instead of failing with a NullPointerException.

-- 
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