Browse Source

Make sure hashvalue algorithm of modified selector reads the files completely. Submitted by Nathan Beyer. PR 48313.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@887838 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
d1e9fb4608
4 changed files with 16 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +7
    -4
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/HashvalueAlgorithm.java

+ 1
- 0
CONTRIBUTORS View File

@@ -226,6 +226,7 @@ Miha
Mike Davis Mike Davis
Mike Roberts Mike Roberts
mnowostawski mnowostawski
Nathan Beyer
Nick Chalko Nick Chalko
Nick Fortescue Nick Fortescue
Nick Crossley Nick Crossley


+ 4
- 0
WHATSNEW View File

@@ -530,6 +530,10 @@ Fixed bugs:
overwrite each others attributes/nested elements. overwrite each others attributes/nested elements.
Bugzilla Report 41602. Bugzilla Report 41602.


* The Hashvalue algortihm implementation of the modified task could
fail to read the file(s) completely.
Bugzilla Report 48313.

Other changes: Other changes:
-------------- --------------




+ 4
- 0
contributors.xml View File

@@ -929,6 +929,10 @@
<name> <name>
<last>mnowostawski</last> <last>mnowostawski</last>
</name> </name>
<name>
<first>Nathan</first>
<last>Beyer</last>
</name>
<name> <name>
<first>Nick</first> <first>Nick</first>
<last>Chalko</last> <last>Chalko</last>


+ 7
- 4
src/main/org/apache/tools/ant/types/selectors/modifiedselector/HashvalueAlgorithm.java View File

@@ -56,11 +56,14 @@ public class HashvalueAlgorithm implements Algorithm {
return null; return null;
} }
java.io.FileInputStream fis = new java.io.FileInputStream(file); java.io.FileInputStream fis = new java.io.FileInputStream(file);
byte[] content = new byte[fis.available()];
fis.read(content);
StringBuffer content = new StringBuffer();
byte[] buffer = new byte[256];
int len = 0;
while ((len = fis.read(buffer, 0, len)) != -1) {
content.append(new String(buffer, 0, len));
}
fis.close(); fis.close();
String s = new String(content);
int hash = s.hashCode();
int hash = content.toString().hashCode();
return Integer.toString(hash); return Integer.toString(hash);
} catch (Exception e) { } catch (Exception e) {
return null; return null;


Loading…
Cancel
Save