tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1382582 - in /tomcat/sandbox/trunk-resources/java/org/apache/catalina: WebResource.java webresources/FileResource.java webresources/StandardRoot.java
Date Sun, 09 Sep 2012 21:25:06 GMT
Author: markt
Date: Sun Sep  9 21:25:05 2012
New Revision: 1382582

URL: http://svn.apache.org/viewvc?rev=1382582&view=rev
Log:
Clarify behaviour of WebResource#getURL() if the resource does not exist and implement the
correct behaviour consistently.

Modified:
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java?rev=1382582&r1=1382581&r2=1382582&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java Sun Sep  9 21:25:05
2012
@@ -122,7 +122,7 @@ public interface WebResource {
 
     /**
      * Obtain a URL to access the resource or <code>null</code> if no such URL
-     * is available.
+     * is available or if the resource does not exist.
      */
     URL getURL();
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java?rev=1382582&r1=1382581&r2=1382582&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java
Sun Sep  9 21:25:05 2012
@@ -146,10 +146,14 @@ public class FileResource implements Web
 
     @Override
     public URL getURL() {
-        try {
-            return resource.toURI().toURL();
-        } catch (MalformedURLException e) {
-            // TODO Log this?
+        if (resource.exists()) {
+            try {
+                return resource.toURI().toURL();
+            } catch (MalformedURLException e) {
+                // TODO Log this?
+                return null;
+            }
+        } else {
             return null;
         }
     }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java?rev=1382582&r1=1382581&r2=1382582&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
Sun Sep  9 21:25:05 2012
@@ -121,7 +121,7 @@ public class StandardRoot extends Lifecy
         }
 
         // Default is empty resource in main resources
-        return main.getResource(path);
+        return new EmptyResource(this, path);
     }
 
     @Override



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


Mime
View raw message