ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44565] New: Date Resource comparator returns incorrect results breaking DependSet
Date Fri, 07 Mar 2008 23:35:28 GMT
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: notifications@ant.apache.org
        ReportedBy: wayne@lewisclan.org


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.

Mime
View raw message