https://issues.apache.org/bugzilla/show_bug.cgi?id=44565
Summary: Date Resource comparator returns incorrect results
breaking DependSet
Product: Ant
Version: 1.7.0
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Core tasks
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
The class org.apache.tools.ant.types.resources.comparators.Date compares the
dates
of two resources. This is used by tasks such as DependSet.
Line 35 in version 1.7.0 is shown below:
return (int) (foo.getLastModified() - bar.getLastModified());
This subtracts two longs and truncates the result to an int. This doesn't work
when the difference between the modification dates reach 2^31 ms which is about
25 days. The result is unpredictable behavior by all code that sorts using
this comparator.
A working alternative is:
long d = foo.getLastModified() - bar.getLastModified();
return ( d < 0 ) ? -1 : ( d > 0 ) ? +1 : 0;
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.