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() {