Timed UUID comparison
Alan Bateman
Alan.Bateman at oracle.com
Mon Jun 21 12:30:12 UTC 2021
On 21/06/2021 12:55, Wouter Wijsman wrote:
> Dear JDK developers,
>
> A couple of weeks ago I found that the compareTo function in the UUID class in Java does not look at timestamps when comparing time based UUIDs. The result of this is that when using this function to sort time based UUIDS, the order seems somewhat random. This was quite surprising to me and caused a bug in one of my applications.
>
> I managed to find out where this comparison is done in the OpenJDK implementation and I made a pull request with a simple fix on Github, but since there is no official bug report for this behavior, it hasn't been reviewed yet. The pull request can be found here: https://github.com/openjdk/jdk/pull/3620
>
> Are there any opinions on this behavior and is this pull request wanted? Otherwise I'll just close it.
It's best to start a discussion on core-libs-dev about the issue and the
use-case. I don't think changing the UUID spec in an incompatible way is
really an option but there may be a case for exposing a Comparator that
compares in timestamp order.
-Alan
More information about the jdk-dev
mailing list