From b887c5c6f279927bd71d1020a593e99717ba8cae Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 7 Aug 2023 11:37:07 +0200 Subject: [PATCH] Fix a regression in CombinerExecutor implementation introduced with the ability to return multiple post actions. --- .../vertx/core/net/impl/pool/CombinerExecutor.java | 9 ++++----- src/main/java/io/vertx/core/net/impl/pool/Task.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/vertx/core/net/impl/pool/CombinerExecutor.java b/src/main/java/io/vertx/core/net/impl/pool/CombinerExecutor.java index 69366fe3731..5acdd797c43 100644 --- a/src/main/java/io/vertx/core/net/impl/pool/CombinerExecutor.java +++ b/src/main/java/io/vertx/core/net/impl/pool/CombinerExecutor.java @@ -56,15 +56,14 @@ public void submit(Action action) { } final Task task = a.execute(state); if (task != null) { + Task last = task.last(); if (head == null) { assert tail == null; - tail = task; - for (Task next = tail.next();next != null;next = tail.next()) { - tail = tail.next(); - } + tail = last; head = task; } else { - tail = tail.next(task); + tail.next(task); + tail = last; } } } diff --git a/src/main/java/io/vertx/core/net/impl/pool/Task.java b/src/main/java/io/vertx/core/net/impl/pool/Task.java index 7d02b6598f4..7ced1366658 100644 --- a/src/main/java/io/vertx/core/net/impl/pool/Task.java +++ b/src/main/java/io/vertx/core/net/impl/pool/Task.java @@ -20,13 +20,21 @@ public Task replaceNext(Task next) { return oldNext; } + public Task last() { + Task current = this; + Task next; + while ((next = current.next) != null) { + current = next; + } + return current; + } + public Task next() { return next; } - public Task next(Task next) { + public void next(Task next) { this.next = next; - return next; } protected final void runNextTasks() {