Timed UUID comparison

Wouter Wijsman wwijsman at live.nl
Mon Jun 21 11:55:40 UTC 2021


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.

Kind regards,
Wouter Wijsman


More information about the jdk-dev mailing list