You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2011/08/18 20:36:28 UTC
[jira] [Commented] (JENA-104) ReverseComparator fails on
Integer.MIN_VALUE
[ https://issues.apache.org/jira/browse/JENA-104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13087180#comment-13087180 ]
Andy Seaborne commented on JENA-104:
------------------------------------
My bad - I was thinking -1,0,+1. The patch is more elegant as well.
> ReverseComparator fails on Integer.MIN_VALUE
> --------------------------------------------
>
> Key: JENA-104
> URL: https://issues.apache.org/jira/browse/JENA-104
> Project: Jena
> Issue Type: Bug
> Reporter: Stephen Allen
> Priority: Minor
> Attachments: JENA-104-r1159330.patch
>
>
> There is a subtle bug in ReverseComparator. If the forward comparator returned Integer.MIN_VALUE, so would the reverse comparator. Using signed integer types, there are more negative numbers available than positive ones (range is -2^31 to 2^31-1 inclusive) and negating the minimum value is effectively a no-op. We can avoid the problem by reversing the order of the arguments instead.
> I've included a patch and tests.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira