• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compartor not working correctly in Windows Server 2012  RSS feed

 
Mike London
Ranch Hand
Posts: 1495
11
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1495
11
  • Mark post as helpful
  • send pies
  • 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: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!