ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r731889 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Checksum.java src/tests/antunit/taskdefs/checksum-test.xml
Date Tue, 06 Jan 2009 09:27:39 GMT
Author: bodewig
Date: Tue Jan  6 01:27:38 2009
New Revision: 731889

URL: http://svn.apache.org/viewvc?rev=731889&view=rev
Log:
make checksum's totalproperty platform independent.  PR 36748.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
    ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=731889&r1=731888&r2=731889&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Jan  6 01:27:38 2009
@@ -121,6 +121,14 @@
    handling on certain Java VMs.
    Bugzilla issue 5003.
 
+ * <checksum>'s totalproperty was platform dependent because it relied
+   on java.io.File#compareTo.  It has now been made platform
+   independent, which means that totalPropery values obtained on
+   Windows (and other systems where the sort order of File is not case
+   sensitive) can be different from the values obtained with earlier
+   versions of Ant.
+   Bugzilla Report 36748.
+
 Fixed bugs:
 -----------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java?rev=731889&r1=731888&r2=731889&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java Tue Jan  6 01:27:38
2009
@@ -27,6 +27,7 @@
 import java.io.FileReader;
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Iterator;
@@ -550,8 +551,18 @@
                 // Convert the keys (source files) into a sorted array.
                 Set keys = allDigests.keySet();
                 Object[] keyArray = keys.toArray();
-                // File is Comparable, so sorting is trivial
-                Arrays.sort(keyArray);
+                // File is Comparable, but sort-order is platform
+                // dependent (case-insensitive on Windows)
+                Arrays.sort(keyArray, new Comparator() {
+                        public int compare(Object o1, Object o2) {
+                            File f1 = (File) o1;
+                            File f2 = (File) o2;
+                            return f1 == null ? (f2 == null ? 0 : -1)
+                                : (f2 == null ? 1
+                                   : f1.getName().compareTo(f2.getName())
+                                   );
+                        }
+                    });
                 // Loop over the checksums and generate a total hash.
                 messageDigest.reset();
                 for (int i = 0; i < keyArray.length; i++) {

Modified: ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml?rev=731889&r1=731888&r2=731889&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml Tue Jan  6 01:27:38 2009
@@ -31,7 +31,7 @@
     <au:assertPropertySet name="checksumsMatch"/>
   </target>
 
-  <target name="xtestTotalPropertyAcrossPlatforms"
+  <target name="testTotalPropertyAcrossPlatforms"
           description="testcase for
           https://issues.apache.org/bugzilla/show_bug.cgi?id=36748">
     <mkdir dir="${input}"/>



Mime
View raw message