ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r709760 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java
Date Sat, 01 Nov 2008 19:41:03 GMT
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;
     }
 
     /**



Mime
View raw message