Fixed json rpc connection confused.(#1260)

This commit is contained in:
李铭昕 2020-01-10 17:02:32 +08:00 committed by GitHub
parent 076f420a07
commit 2dab5f3e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -3,6 +3,7 @@
## Fixed
- [#1258](https://github.com/hyperf/hyperf/pull/1258) Fixed CRITICAL error that socket of process is unavailable when amqp send heartbeat failed.
- [#1260](https://github.com/hyperf/hyperf/pull/1260) Fixed json rpc connection confused.
# v1.1.14 - 2010-01-10

View File

@ -111,7 +111,7 @@ class JsonRpcPoolTransporter implements TransporterInterface
*/
public function getConnection(): RpcConnection
{
$class = static::class . '.Connection';
$class = spl_object_hash($this) . '.Connection';
if (Context::has($class)) {
return Context::get($class);
}

View File

@ -83,7 +83,7 @@ class JsonRpcTransporter implements TransporterInterface
public function getClient(): SwooleClient
{
$class = static::class . '.Connection';
$class = spl_object_hash($this) . '.Connection';
if (Context::has($class)) {
return Context::get($class);
}

View File

@ -97,6 +97,18 @@ class JsonRpcPoolTransporterTest extends TestCase
$this->assertSame($data, $packer->unpack($string));
}
public function testsplObjectHash()
{
$class = new \stdClass();
$class->id = 1;
$hash = spl_object_hash($class);
$class->id = 2;
$hash2 = spl_object_hash($class);
$this->assertSame($hash, $hash2);
}
protected function getContainer()
{
$container = Mockery::mock(Container::class);