Browse Source

make checksum's totalproperty platform independent. PR 36748.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@731889 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
6c29cfdd70
3 changed files with 22 additions and 3 deletions
  1. +8
    -0
      WHATSNEW
  2. +13
    -2
      src/main/org/apache/tools/ant/taskdefs/Checksum.java
  3. +1
    -1
      src/tests/antunit/taskdefs/checksum-test.xml

+ 8
- 0
WHATSNEW View File

@@ -121,6 +121,14 @@ Changes that could break older environments:
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:
-----------



+ 13
- 2
src/main/org/apache/tools/ant/taskdefs/Checksum.java View File

@@ -27,6 +27,7 @@ import java.io.FileInputStream;
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 @@ public class Checksum extends MatchingTask implements Condition {
// 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++) {


+ 1
- 1
src/tests/antunit/taskdefs/checksum-test.xml View File

@@ -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}"/>


Loading…
Cancel
Save