ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r718482 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
Date Tue, 18 Nov 2008 04:55:25 GMT
Author: bodewig
Date: Mon Nov 17 20:55:25 2008
New Revision: 718482

URL: http://svn.apache.org/viewvc?rev=718482&view=rev
Log:
re-instante contract of resourceCompare by throwing ClassCastException for non-FileProviders

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java?rev=718482&r1=718481&r2=718482&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
Mon Nov 17 20:55:25 2008
@@ -38,8 +38,18 @@
      * @throws ClassCastException if either resource is not an instance of FileResource.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        File foofile = ((FileProvider) foo.as(FileProvider.class)).getFile();
-        File barfile = ((FileProvider) bar.as(FileProvider.class)).getFile();
+        FileProvider fooFP = (FileProvider) foo.as(FileProvider.class);
+        if (fooFP == null) {
+            throw new ClassCastException(foo.getClass()
+                                         + " doesn't provide files");
+        }
+        File foofile = fooFP.getFile();
+        FileProvider barFP = (FileProvider) bar.as(FileProvider.class);
+        if (barFP == null) {
+            throw new ClassCastException(bar.getClass()
+                                         + " doesn't provide files");
+        }
+        File barfile = barFP.getFile();
         return foofile.equals(barfile) ? 0
             : FILE_UTILS.isLeadingPath(foofile, barfile) ? -1
             : FILE_UTILS.normalize(foofile.getAbsolutePath()).compareTo(



Mime
View raw message