This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch mvnd-1.x in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
commit e4828fdf98beb1386d26b28e013a1d259de35de6 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 9c15c2af..459f771e 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; }