• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Compartor not working correctly in Windows Server 2012

 
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a basic file comparator that works correctly in Windows 2003 Server, but does not work correctly in Windows 2012 Server:


.
.
.


The latest file is not correctly sorted.

Any obvious reasons for this difference?

Thanks,

-mike
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike London wrote:


That's probably the cause. When you truncate the last modification timestamps, you lose information. Those ints may very well be negative. Use Long.compare instead:
The static compare methods have been added in Java 7 to all of the primitive wrappers (including Boolean). There is no need to box primitives anymore.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Mike London wrote:


That's probably the cause. When you truncate the last modification timestamps, you lose information. Those ints may very well be negative. Use Long.compare instead:
The static compare methods have been added in Java 7 to all of the primitive wrappers (including Boolean). There is no need to box primitives anymore.



Yes, it was old code, thanks!

My issue appeared to be that in the old code, possibly due to the issue you raised, I was taking the last value in the list, which works on Windows 2003 server and earlier versions of the JDK. However, in Java 8 and Windows 2012 server (assuming Windows has nothing to actually do with any of this), I need the top value on the sorted list.

However, I get the same results with the old code and the new (your) code.

In any case, I've simplified that ugly boxing from the old code and made it much cleaner looking.

Thanks!!!

- mike
 
Rob Spoor
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic