This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
commit 64c0a8fdf4744f917362861c7938a9d41d31cf3d Author: Tamas Cservenak <ta...@cservenak.net> AuthorDate: Sat Nov 23 15:12:45 2024 +0100 Fix log ordering nano time is not enough, rather use a "sequence" --- common/src/main/java/org/mvndaemon/mvnd/common/Message.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Message.java b/common/src/main/java/org/mvndaemon/mvnd/common/Message.java index d6ebc268..6c7de2b7 100644 --- a/common/src/main/java/org/mvndaemon/mvnd/common/Message.java +++ b/common/src/main/java/org/mvndaemon/mvnd/common/Message.java @@ -31,6 +31,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; public abstract class Message { public static final int BUILD_REQUEST = 1; @@ -125,10 +126,13 @@ public abstract class Message { throw new IllegalStateException("Unexpected message type: " + type); } + private static final AtomicLong sequence = new AtomicLong(); + + final long seq = sequence.incrementAndGet(); final long timestamp = System.nanoTime(); public static Comparator<Message> getMessageComparator() { - return Comparator.comparingInt(Message::getClassOrder).thenComparingLong(Message::timestamp); + return Comparator.comparingInt(Message::getClassOrder).thenComparingLong(Message::seq); } public static int getClassOrder(Message m) { @@ -178,6 +182,10 @@ public abstract class Message { } } + public long seq() { + return seq; + } + public long timestamp() { return timestamp; }