You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by st...@apache.org on 2008/11/01 20:41:03 UTC

svn commit: r709760 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java

Author: stevel
Date: Sat Nov  1 12:41:03 2008
New Revision: 709760

URL: http://svn.apache.org/viewvc?rev=709760&view=rev
Log:
Bug ID 43660: JavaResource returns a null input stream if the resource is missing

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java?rev=709760&r1=709759&r2=709760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java Sat Nov  1 12:41:03 2008
@@ -17,6 +17,7 @@
  */
 package org.apache.tools.ant.types.resources;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -53,8 +54,21 @@
      * @throws IOException if an error occurs.
      */
     protected InputStream openInputStream(ClassLoader cl) throws IOException {
-        return cl == null ? ClassLoader.getSystemResourceAsStream(getName())
-            : cl.getResourceAsStream(getName());
+        InputStream inputStream;
+        if (cl == null) {
+            inputStream = ClassLoader.getSystemResourceAsStream(getName());
+            if (inputStream == null) {
+                throw new FileNotFoundException("No resource " + getName()
+                        + " on Ant's classpath");
+            }
+        } else {
+            inputStream = cl.getResourceAsStream(getName());
+            if (inputStream == null) {
+                throw new FileNotFoundException("No resource " + getName()
+                        + " on the classpath " + cl);
+            }
+        }
+        return inputStream;
     }
 
     /**