Bug 41411 - Bug in org.apache.tools.ant.types.resources.comparators.Date
Summary: Bug in org.apache.tools.ant.types.resources.comparators.Date
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal (vote)
Target Milestone: 1.7.1
Assignee: Ant Notifications List
URL:
Keywords:
: 42774 44565 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-01-19 06:08 UTC by Cedomir Igaly
Modified: 2008-03-07 15:42 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cedomir Igaly 2007-01-19 06:08:30 UTC
protected int resourceCompare(Resource foo, Resource bar) {
        return (int) (foo.getLastModified() - bar.getLastModified());
    }

When difference foo.getLastModified() - bar.getLastModified() is greater than
Integer.MAX_VALUE or less than Integer.MIN_VALUE, result returned by
resourceCompare is undefined. Possible fix is:

    protected int resourceCompare(Resource foo, Resource bar) {
        long diff = foo.getLastModified() - bar.getLastModified();
        if (diff > 0) {
            return +1;
        } else if (diff < 0) {
            return -1;
        } else {
            return 0;
        }
    }
Comment 1 J.M. (Martijn) Kruithof 2007-01-27 13:09:46 UTC
Thanks fixed in head.
Comment 2 J.M. (Martijn) Kruithof 2007-06-29 10:31:17 UTC
*** Bug 42774 has been marked as a duplicate of this bug. ***
Comment 3 Matt Benson 2008-03-07 15:42:26 UTC
*** Bug 44565 has been marked as a duplicate of this bug. ***