From 793d431867237cc00f45594e557408fd060a271c Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Fri, 14 Nov 2025 22:30:03 +0800 Subject: [PATCH] fix: correct pool property initialization in dispatch classes - Change pool property from non-nullable string with default value to nullable string in PendingAsyncQueueDispatch and PendingKafkaProducerMessageDispatch - Update __destruct() methods to use null coalescing operator (??) for default pool fallback - Fix test assertion to expect null instead of 'default' for pool property - This maintains backward compatibility while allowing proper pool configuration --- src/support/src/Bus/PendingAsyncQueueDispatch.php | 4 ++-- src/support/src/Bus/PendingKafkaProducerMessageDispatch.php | 4 ++-- tests/Support/DispatchTest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/support/src/Bus/PendingAsyncQueueDispatch.php b/src/support/src/Bus/PendingAsyncQueueDispatch.php index 50aa8cf8e..e206c4c90 100644 --- a/src/support/src/Bus/PendingAsyncQueueDispatch.php +++ b/src/support/src/Bus/PendingAsyncQueueDispatch.php @@ -20,7 +20,7 @@ class PendingAsyncQueueDispatch { use Conditionable; - public string $pool = 'default'; + public ?string $pool = null; public int $delay = 0; @@ -32,7 +32,7 @@ public function __destruct() { ApplicationContext::getContainer() ->get(DriverFactory::class) - ->get($this->pool) + ->get($this->pool ?? 'default') ->push($this->job, $this->delay); } diff --git a/src/support/src/Bus/PendingKafkaProducerMessageDispatch.php b/src/support/src/Bus/PendingKafkaProducerMessageDispatch.php index 8ce23e4d9..13671f111 100644 --- a/src/support/src/Bus/PendingKafkaProducerMessageDispatch.php +++ b/src/support/src/Bus/PendingKafkaProducerMessageDispatch.php @@ -26,7 +26,7 @@ class PendingKafkaProducerMessageDispatch { use Conditionable; - public string $pool = 'default'; + public ?string $pool = null; public function __construct(protected ProduceMessage $message) { @@ -36,7 +36,7 @@ public function __destruct() { ApplicationContext::getContainer() ->get(ProducerManager::class) - ->getProducer($this->pool) + ->getProducer($this->pool ?? 'default') ->sendBatch([$this->message]); } diff --git a/tests/Support/DispatchTest.php b/tests/Support/DispatchTest.php index b2d615ebd..1360d01f0 100644 --- a/tests/Support/DispatchTest.php +++ b/tests/Support/DispatchTest.php @@ -447,7 +447,7 @@ public function testBackwardCompatibilityWithBasicDispatch() $pending = dispatch($job); // Verify defaults - $this->assertEquals('default', $this->getProperty($pending, 'pool')); + $this->assertNull($this->getProperty($pending, 'pool')); $this->assertEquals(0, $this->getProperty($pending, 'delay')); // Trigger destruct