This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 6c13a560b0 Revert "fix: preserve Runnable hash codes in 
PekkoForkJoinTask (#3668)" (#3681)
6c13a560b0 is described below

commit 6c13a560b006751e98274fad424a06267fdd150a
Author: PJ Fanning <[email protected]>
AuthorDate: Sat Oct 24 13:31:15 2026 +0100

    Revert "fix: preserve Runnable hash codes in PekkoForkJoinTask (#3668)" 
(#3681)
    
    Motivation:
    #3668 made PekkoForkJoinTask delegate hashCode to its Runnable. No caller
    needs this, and it makes hashing of dispatcher tasks worse. The follow-up
    #3669, which removed the override, was abandoned.
    
    Modification:
    Revert #3668, restoring the inherited identity hashCode and removing the
    tests that asserted the delegated hash.
    
    Result:
    Each PekkoForkJoinTask again has its own identity hash, matching its
    identity equality and per-submission semantics.
    
    Tests:
    - Not run locally - straight revert to the pre-#3668 code; CI validates.
    
    References:
    Refs #3668, Refs #3669.
---
 .../pekko/dispatch/MailboxTaskSubmissionSpec.scala | 47 +---------------------
 .../dispatch/ForkJoinExecutorConfigurator.scala    |  7 ----
 2 files changed, 1 insertion(+), 53 deletions(-)

diff --git 
a/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxTaskSubmissionSpec.scala
 
b/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxTaskSubmissionSpec.scala
index 597d9b8261..ad731104fc 100644
--- 
a/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxTaskSubmissionSpec.scala
+++ 
b/actor-tests/src/test/scala/org/apache/pekko/dispatch/MailboxTaskSubmissionSpec.scala
@@ -21,7 +21,7 @@ import java.util.concurrent.{ ForkJoinPool, ForkJoinTask, 
ForkJoinWorkerThread }
 import java.util.concurrent.atomic.{ AtomicBoolean, AtomicInteger }
 
 import org.apache.pekko
-import pekko.dispatch.ForkJoinExecutorConfigurator.{ PekkoForkJoinPool, 
PekkoForkJoinTask }
+import pekko.dispatch.ForkJoinExecutorConfigurator.PekkoForkJoinPool
 import pekko.testkit.PekkoSpec
 
 /**
@@ -75,51 +75,6 @@ class MailboxTaskSubmissionSpec extends PekkoSpec {
     }
   }
 
-  "PekkoForkJoinTask" must {
-
-    "preserve the Runnable hash code across fresh wrappers" in {
-      for (hash <- Seq(Int.MinValue, -1, 0, 1, Int.MaxValue)) {
-        val runnable = new Runnable {
-          final override def run(): Unit = ()
-          final override def hashCode(): Int = hash
-        }
-        val first = new PekkoForkJoinTask(runnable)
-        val second = new PekkoForkJoinTask(runnable)
-
-        withClue(s"Runnable hash code $hash: ") {
-          first.hashCode() shouldBe hash
-          second.hashCode() shouldBe hash
-          (first should not).equal(second)
-        }
-      }
-    }
-
-    "retain independent completion and cancellation for wrappers with the same 
hash code" in {
-      val runs = new AtomicInteger(0)
-      val runnable = new Runnable {
-        final override def run(): Unit = { runs.incrementAndGet() }
-        final override def hashCode(): Int = 42
-      }
-      val cancelled = new PekkoForkJoinTask(runnable)
-      val completed = new PekkoForkJoinTask(runnable)
-      val pending = new PekkoForkJoinTask(runnable)
-
-      cancelled.cancel(false) shouldBe true
-      completed.invoke()
-
-      cancelled.isCancelled shouldBe true
-      completed.isCompletedNormally shouldBe true
-      pending.isDone shouldBe false
-      runs.get() shouldBe 1
-      Set(cancelled, completed, pending).size shouldBe 3
-      Seq(cancelled, completed, pending).foreach(_.hashCode() shouldBe 42)
-
-      pending.invoke()
-      pending.isCompletedNormally shouldBe true
-      runs.get() shouldBe 2
-    }
-  }
-
   "PekkoForkJoinPool" must {
 
     "not run a cancelled ForkJoinTask submitted as a Runnable" in {
diff --git 
a/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala
 
b/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala
index 387b78a554..5b056398fb 100644
--- 
a/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala
+++ 
b/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala
@@ -77,13 +77,6 @@ object ForkJoinExecutorConfigurator {
    */
   @SerialVersionUID(1L)
   final class PekkoForkJoinTask(runnable: Runnable) extends ForkJoinTask[Unit] 
{
-
-    /**
-     * Preserve the wrapped Runnable's hash code across fresh task wrappers, 
provided that the
-     * Runnable's hash code is stable. Each wrapper retains its own identity 
and completion state.
-     */
-    final override def hashCode(): Int = runnable.hashCode()
-
     override def getRawResult(): Unit = ()
     override def setRawResult(unit: Unit): Unit = ()
     override def exec(): Boolean =


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to