cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r394742 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpContext.java
Date Mon, 17 Apr 2006 18:06:37 GMT
Author: danielf
Date: Mon Apr 17 11:06:36 2006
New Revision: 394742

URL: http://svn.apache.org/viewcvs?rev=394742&view=rev
Log:
Avoid NPE when in an environment without web.xml.

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpContext.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpContext.java?rev=394742&r1=394741&r2=394742&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpContext.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpContext.java
Mon Apr 17 11:06:36 2006
@@ -73,7 +73,12 @@
             if (value == null) {
                 // Try to figure out the path of the root from that of WEB-INF
                 try {
-                value = this.servletContext.getResource("/WEB-INF/web.xml").toString();
+                    URL webXml = this.servletContext.getResource("/WEB-INF/web.xml");
+                    // In some contexts there might not be any web.xml, then we stop
+                    // guessing an just return null, which follows the servlet specification
+                    if (webXml == null)
+                        return null;
+                    value = webXml.toString();
                 } catch (MalformedURLException mue) {
                     throw new ContextURLException("Cannot determine the base URL for " +
path, mue);
                 }



Mime
View raw message